From 137cb579d1967862f9081e140c9a5a6f350093ed Mon Sep 17 00:00:00 2001 From: David Barksdale Date: Mon, 1 Aug 2016 19:21:22 -0500 Subject: Deleted a bunch of files --- .../ksdk_platform_lib/armgcc/KL27Z4/CMakeLists.txt | 0 .../src/sim/MK02F12810/fsl_sim_hal_MK02F12810.c | 762 ----- .../src/sim/MK02F12810/fsl_sim_hal_MK02F12810.h | 1125 -------- .../hal/src/sim/MK10D10/fsl_sim_hal_MK10D10.c | 750 ----- .../hal/src/sim/MK10D10/fsl_sim_hal_MK10D10.h | 1731 ----------- .../hal/src/sim/MK11DA5/fsl_sim_hal_MK11DA5.c | 685 ----- .../hal/src/sim/MK11DA5/fsl_sim_hal_MK11DA5.h | 1221 -------- .../hal/src/sim/MK20D10/fsl_sim_hal_MK20D10.c | 750 ----- .../hal/src/sim/MK20D10/fsl_sim_hal_MK20D10.h | 1731 ----------- .../hal/src/sim/MK21DA5/fsl_sim_hal_MK21DA5.c | 715 ----- .../hal/src/sim/MK21DA5/fsl_sim_hal_MK21DA5.h | 1435 ---------- .../hal/src/sim/MK21FA12/fsl_sim_hal_MK21FA12.c | 786 ----- .../hal/src/sim/MK21FA12/fsl_sim_hal_MK21FA12.h | 1578 ---------- .../src/sim/MK22F12810/fsl_sim_hal_MK22F12810.c | 813 ------ .../src/sim/MK22F12810/fsl_sim_hal_MK22F12810.h | 1416 --------- .../src/sim/MK22F25612/fsl_sim_hal_MK22F25612.c | 813 ------ .../src/sim/MK22F25612/fsl_sim_hal_MK22F25612.h | 1601 ----------- .../src/sim/MK22F51212/fsl_sim_hal_MK22F51212.c | 853 ------ .../src/sim/MK22F51212/fsl_sim_hal_MK22F51212.h | 1666 ----------- .../hal/src/sim/MK24F12/fsl_sim_hal_MK24F12.c | 786 ----- .../hal/src/sim/MK24F12/fsl_sim_hal_MK24F12.h | 1627 ----------- .../src/sim/MK24F25612/fsl_sim_hal_MK24F25612.c | 779 ----- .../src/sim/MK24F25612/fsl_sim_hal_MK24F25612.h | 1408 --------- .../hal/src/sim/MK26F18/fsl_sim_hal_MK26F18.c | 1037 ------- .../hal/src/sim/MK26F18/fsl_sim_hal_MK26F18.h | 2104 -------------- .../hal/src/sim/MK30D10/fsl_sim_hal_MK30D10.c | 750 ----- .../hal/src/sim/MK30D10/fsl_sim_hal_MK30D10.h | 1731 ----------- .../hal/src/sim/MK40D10/fsl_sim_hal_MK40D10.c | 750 ----- .../hal/src/sim/MK40D10/fsl_sim_hal_MK40D10.h | 1731 ----------- .../hal/src/sim/MK50D10/fsl_sim_hal_MK50D10.c | 750 ----- .../hal/src/sim/MK50D10/fsl_sim_hal_MK50D10.h | 1731 ----------- .../hal/src/sim/MK51D10/fsl_sim_hal_MK51D10.c | 750 ----- .../hal/src/sim/MK51D10/fsl_sim_hal_MK51D10.h | 1731 ----------- .../hal/src/sim/MK52D10/fsl_sim_hal_MK52D10.c | 750 ----- .../hal/src/sim/MK52D10/fsl_sim_hal_MK52D10.h | 1731 ----------- .../hal/src/sim/MK53D10/fsl_sim_hal_MK53D10.c | 750 ----- .../hal/src/sim/MK53D10/fsl_sim_hal_MK53D10.h | 1731 ----------- .../hal/src/sim/MK60D10/fsl_sim_hal_MK60D10.c | 750 ----- .../hal/src/sim/MK60D10/fsl_sim_hal_MK60D10.h | 1731 ----------- .../hal/src/sim/MK63F12/fsl_sim_hal_MK63F12.c | 786 ----- .../hal/src/sim/MK63F12/fsl_sim_hal_MK63F12.h | 1704 ----------- .../hal/src/sim/MK64F12/fsl_sim_hal_MK64F12.c | 786 ----- .../hal/src/sim/MK64F12/fsl_sim_hal_MK64F12.h | 1704 ----------- .../hal/src/sim/MK65F18/fsl_sim_hal_MK65F18.c | 1037 ------- .../hal/src/sim/MK65F18/fsl_sim_hal_MK65F18.h | 2191 -------------- .../hal/src/sim/MK66F18/fsl_sim_hal_MK66F18.c | 1037 ------- .../hal/src/sim/MK66F18/fsl_sim_hal_MK66F18.h | 2191 -------------- .../hal/src/sim/MKL02Z4/fsl_sim_hal_MKL02Z4.c | 315 -- .../hal/src/sim/MKL02Z4/fsl_sim_hal_MKL02Z4.h | 842 ------ .../hal/src/sim/MKL03Z4/fsl_sim_hal_MKL03Z4.c | 167 -- .../hal/src/sim/MKL03Z4/fsl_sim_hal_MKL03Z4.h | 1062 ------- .../hal/src/sim/MKL14Z4/fsl_sim_hal_MKL14Z4.c | 378 --- .../hal/src/sim/MKL14Z4/fsl_sim_hal_MKL14Z4.h | 1298 --------- .../hal/src/sim/MKL15Z4/fsl_sim_hal_MKL15Z4.c | 378 --- .../hal/src/sim/MKL15Z4/fsl_sim_hal_MKL15Z4.h | 1298 --------- .../hal/src/sim/MKL16Z4/fsl_sim_hal_MKL16Z4.c | 378 --- .../hal/src/sim/MKL16Z4/fsl_sim_hal_MKL16Z4.h | 1397 --------- .../hal/src/sim/MKL17Z4/fsl_sim_hal_MKL17Z4.c | 384 --- .../hal/src/sim/MKL17Z4/fsl_sim_hal_MKL17Z4.h | 1371 --------- .../hal/src/sim/MKL17Z644/fsl_sim_hal_MKL17Z644.c | 384 --- .../hal/src/sim/MKL17Z644/fsl_sim_hal_MKL17Z644.h | 1124 -------- .../hal/src/sim/MKL24Z4/fsl_sim_hal_MKL24Z4.c | 378 --- .../hal/src/sim/MKL24Z4/fsl_sim_hal_MKL24Z4.h | 1298 --------- .../hal/src/sim/MKL25Z4/fsl_sim_hal_MKL25Z4.c | 378 --- .../hal/src/sim/MKL25Z4/fsl_sim_hal_MKL25Z4.h | 1298 --------- .../hal/src/sim/MKL26Z4/fsl_sim_hal_MKL26Z4.c | 378 --- .../hal/src/sim/MKL26Z4/fsl_sim_hal_MKL26Z4.h | 1397 --------- .../hal/src/sim/MKL27Z644/fsl_sim_hal_MKL27Z644.c | 384 --- .../hal/src/sim/MKL27Z644/fsl_sim_hal_MKL27Z644.h | 1124 -------- .../hal/src/sim/MKL33Z4/fsl_sim_hal_MKL33Z4.c | 384 --- .../hal/src/sim/MKL33Z4/fsl_sim_hal_MKL33Z4.h | 1371 --------- .../hal/src/sim/MKL34Z4/fsl_sim_hal_MKL34Z4.c | 378 --- .../hal/src/sim/MKL34Z4/fsl_sim_hal_MKL34Z4.h | 1397 --------- .../hal/src/sim/MKL36Z4/fsl_sim_hal_MKL36Z4.c | 378 --- .../hal/src/sim/MKL36Z4/fsl_sim_hal_MKL36Z4.h | 1397 --------- .../hal/src/sim/MKL43Z4/fsl_sim_hal_MKL43Z4.c | 384 --- .../hal/src/sim/MKL43Z4/fsl_sim_hal_MKL43Z4.h | 1371 --------- .../hal/src/sim/MKL46Z4/fsl_sim_hal_MKL46Z4.c | 378 --- .../hal/src/sim/MKL46Z4/fsl_sim_hal_MKL46Z4.h | 1397 --------- .../hal/src/sim/MKV10Z7/fsl_sim_hal_MKV10Z7.c | 946 ------ .../hal/src/sim/MKV10Z7/fsl_sim_hal_MKV10Z7.h | 1130 -------- .../src/sim/MKV30F12810/fsl_sim_hal_MKV30F12810.c | 787 ----- .../src/sim/MKV30F12810/fsl_sim_hal_MKV30F12810.h | 1095 ------- .../src/sim/MKV31F12810/fsl_sim_hal_MKV31F12810.c | 771 ----- .../src/sim/MKV31F12810/fsl_sim_hal_MKV31F12810.h | 1199 -------- .../src/sim/MKV31F25612/fsl_sim_hal_MKV31F25612.c | 771 ----- .../src/sim/MKV31F25612/fsl_sim_hal_MKV31F25612.h | 1201 -------- .../src/sim/MKV31F51212/fsl_sim_hal_MKV31F51212.c | 823 ------ .../src/sim/MKV31F51212/fsl_sim_hal_MKV31F51212.h | 1275 --------- .../hal/src/sim/MKV40F15/fsl_sim_hal_MKV40F15.c | 2694 ----------------- .../hal/src/sim/MKV40F15/fsl_sim_hal_MKV40F15.h | 3018 -------------------- .../hal/src/sim/MKV43F15/fsl_sim_hal_MKV43F15.c | 2274 --------------- .../hal/src/sim/MKV43F15/fsl_sim_hal_MKV43F15.h | 3018 -------------------- .../hal/src/sim/MKV44F15/fsl_sim_hal_MKV44F15.c | 2274 --------------- .../hal/src/sim/MKV44F15/fsl_sim_hal_MKV44F15.h | 3018 -------------------- .../hal/src/sim/MKV45F15/fsl_sim_hal_MKV45F15.c | 2694 ----------------- .../hal/src/sim/MKV45F15/fsl_sim_hal_MKV45F15.h | 3018 -------------------- .../hal/src/sim/MKV46F15/fsl_sim_hal_MKV46F15.c | 2694 ----------------- .../hal/src/sim/MKV46F15/fsl_sim_hal_MKV46F15.h | 3018 -------------------- .../hal/src/sim/MKW01Z4/fsl_sim_hal_MKW01Z4.c | 378 --- .../hal/src/sim/MKW01Z4/fsl_sim_hal_MKW01Z4.h | 1397 --------- .../hal/src/sim/MKW21D5/fsl_sim_hal_MKW21D5.c | 704 ----- .../hal/src/sim/MKW21D5/fsl_sim_hal_MKW21D5.h | 1221 -------- .../hal/src/sim/MKW22D5/fsl_sim_hal_MKW22D5.c | 734 ----- .../hal/src/sim/MKW22D5/fsl_sim_hal_MKW22D5.h | 1436 ---------- .../hal/src/sim/MKW24D5/fsl_sim_hal_MKW24D5.c | 734 ----- .../hal/src/sim/MKW24D5/fsl_sim_hal_MKW24D5.h | 1437 ---------- .../src/clock/MK02F12810/fsl_clock_MK02F12810.c | 807 ------ .../src/clock/MK02F12810/fsl_clock_MK02F12810.h | 1116 -------- .../system/src/clock/MK10D10/fsl_clock_MK10D10.c | 1075 ------- .../system/src/clock/MK10D10/fsl_clock_MK10D10.h | 2048 ------------- .../system/src/clock/MK11DA5/fsl_clock_MK11DA5.c | 861 ------ .../system/src/clock/MK11DA5/fsl_clock_MK11DA5.h | 1436 ---------- .../system/src/clock/MK20D10/fsl_clock_MK20D10.c | 1075 ------- .../system/src/clock/MK20D10/fsl_clock_MK20D10.h | 2048 ------------- .../system/src/clock/MK21DA5/fsl_clock_MK21DA5.c | 891 ------ .../system/src/clock/MK21DA5/fsl_clock_MK21DA5.h | 1462 ---------- .../system/src/clock/MK21FA12/fsl_clock_MK21FA12.c | 965 ------- .../system/src/clock/MK21FA12/fsl_clock_MK21FA12.h | 1712 ----------- .../src/clock/MK22F12810/fsl_clock_MK22F12810.c | 883 ------ .../src/clock/MK22F12810/fsl_clock_MK22F12810.h | 1450 ---------- .../src/clock/MK22F25612/fsl_clock_MK22F25612.c | 889 ------ .../src/clock/MK22F25612/fsl_clock_MK22F25612.h | 1486 ---------- .../src/clock/MK22F51212/fsl_clock_MK22F51212.c | 954 ------- .../src/clock/MK22F51212/fsl_clock_MK22F51212.h | 1545 ---------- .../system/src/clock/MK24F12/fsl_clock_MK24F12.c | 970 ------- .../system/src/clock/MK24F12/fsl_clock_MK24F12.h | 1703 ----------- .../src/clock/MK24F25612/fsl_clock_MK24F25612.c | 900 ------ .../src/clock/MK24F25612/fsl_clock_MK24F25612.h | 1467 ---------- .../system/src/clock/MK26F18/fsl_clock_MK26F18.c | 1219 -------- .../system/src/clock/MK26F18/fsl_clock_MK26F18.h | 2093 -------------- .../system/src/clock/MK30D10/fsl_clock_MK30D10.c | 1075 ------- .../system/src/clock/MK30D10/fsl_clock_MK30D10.h | 2048 ------------- .../system/src/clock/MK40D10/fsl_clock_MK40D10.c | 1075 ------- .../system/src/clock/MK40D10/fsl_clock_MK40D10.h | 2048 ------------- .../system/src/clock/MK50D10/fsl_clock_MK50D10.c | 1075 ------- .../system/src/clock/MK50D10/fsl_clock_MK50D10.h | 2048 ------------- .../system/src/clock/MK51D10/fsl_clock_MK51D10.c | 1075 ------- .../system/src/clock/MK51D10/fsl_clock_MK51D10.h | 2048 ------------- .../system/src/clock/MK52D10/fsl_clock_MK52D10.c | 1075 ------- .../system/src/clock/MK52D10/fsl_clock_MK52D10.h | 2048 ------------- .../system/src/clock/MK53D10/fsl_clock_MK53D10.c | 1075 ------- .../system/src/clock/MK53D10/fsl_clock_MK53D10.h | 2048 ------------- .../system/src/clock/MK60D10/fsl_clock_MK60D10.c | 1075 ------- .../system/src/clock/MK60D10/fsl_clock_MK60D10.h | 2048 ------------- .../system/src/clock/MK63F12/fsl_clock_MK63F12.c | 1026 ------- .../system/src/clock/MK63F12/fsl_clock_MK63F12.h | 1834 ------------ .../system/src/clock/MK64F12/fsl_clock_MK64F12.c | 1026 ------- .../system/src/clock/MK64F12/fsl_clock_MK64F12.h | 1834 ------------ .../system/src/clock/MK65F18/fsl_clock_MK65F18.c | 1275 --------- .../system/src/clock/MK65F18/fsl_clock_MK65F18.h | 2222 -------------- .../system/src/clock/MK66F18/fsl_clock_MK66F18.c | 1275 --------- .../system/src/clock/MK66F18/fsl_clock_MK66F18.h | 2222 -------------- .../system/src/clock/MKL02Z4/fsl_clock_MKL02Z4.c | 723 ----- .../system/src/clock/MKL02Z4/fsl_clock_MKL02Z4.h | 675 ----- .../system/src/clock/MKL03Z4/fsl_clock_MKL03Z4.c | 704 ----- .../system/src/clock/MKL03Z4/fsl_clock_MKL03Z4.h | 812 ------ .../system/src/clock/MKL14Z4/fsl_clock_MKL14Z4.c | 986 ------- .../system/src/clock/MKL14Z4/fsl_clock_MKL14Z4.h | 1115 -------- .../system/src/clock/MKL15Z4/fsl_clock_MKL15Z4.c | 986 ------- .../system/src/clock/MKL15Z4/fsl_clock_MKL15Z4.h | 1115 -------- .../system/src/clock/MKL16Z4/fsl_clock_MKL16Z4.c | 1012 ------- .../system/src/clock/MKL16Z4/fsl_clock_MKL16Z4.h | 1237 -------- .../system/src/clock/MKL17Z4/fsl_clock_MKL17Z4.c | 840 ------ .../system/src/clock/MKL17Z4/fsl_clock_MKL17Z4.h | 1323 --------- .../src/clock/MKL17Z644/fsl_clock_MKL17Z644.c | 804 ------ .../src/clock/MKL17Z644/fsl_clock_MKL17Z644.h | 1193 -------- .../system/src/clock/MKL24Z4/fsl_clock_MKL24Z4.c | 986 ------- .../system/src/clock/MKL24Z4/fsl_clock_MKL24Z4.h | 1115 -------- .../system/src/clock/MKL25Z4/fsl_clock_MKL25Z4.c | 986 ------- .../system/src/clock/MKL25Z4/fsl_clock_MKL25Z4.h | 1115 -------- .../system/src/clock/MKL26Z4/fsl_clock_MKL26Z4.c | 1012 ------- .../system/src/clock/MKL26Z4/fsl_clock_MKL26Z4.h | 1237 -------- .../src/clock/MKL27Z644/fsl_clock_MKL27Z644.c | 804 ------ .../src/clock/MKL27Z644/fsl_clock_MKL27Z644.h | 1193 -------- .../system/src/clock/MKL33Z4/fsl_clock_MKL33Z4.c | 840 ------ .../system/src/clock/MKL33Z4/fsl_clock_MKL33Z4.h | 1323 --------- .../system/src/clock/MKL34Z4/fsl_clock_MKL34Z4.c | 1012 ------- .../system/src/clock/MKL34Z4/fsl_clock_MKL34Z4.h | 1237 -------- .../system/src/clock/MKL36Z4/fsl_clock_MKL36Z4.c | 1012 ------- .../system/src/clock/MKL36Z4/fsl_clock_MKL36Z4.h | 1237 -------- .../system/src/clock/MKL43Z4/fsl_clock_MKL43Z4.c | 840 ------ .../system/src/clock/MKL43Z4/fsl_clock_MKL43Z4.h | 1323 --------- .../system/src/clock/MKL46Z4/fsl_clock_MKL46Z4.c | 1012 ------- .../system/src/clock/MKL46Z4/fsl_clock_MKL46Z4.h | 1237 -------- .../system/src/clock/MKV10Z7/fsl_clock_MKV10Z7.c | 806 ------ .../system/src/clock/MKV10Z7/fsl_clock_MKV10Z7.h | 926 ------ .../src/clock/MKV30F12810/fsl_clock_MKV30F12810.c | 809 ------ .../src/clock/MKV30F12810/fsl_clock_MKV30F12810.h | 1119 -------- .../src/clock/MKV31F12810/fsl_clock_MKV31F12810.c | 848 ------ .../src/clock/MKV31F12810/fsl_clock_MKV31F12810.h | 1198 -------- .../src/clock/MKV31F25612/fsl_clock_MKV31F25612.c | 854 ------ .../src/clock/MKV31F25612/fsl_clock_MKV31F25612.h | 1232 -------- .../src/clock/MKV31F51212/fsl_clock_MKV31F51212.c | 871 ------ .../src/clock/MKV31F51212/fsl_clock_MKV31F51212.h | 1299 --------- .../system/src/clock/MKV40F15/fsl_clock_MKV40F15.c | 765 ----- .../system/src/clock/MKV40F15/fsl_clock_MKV40F15.h | 1267 -------- .../system/src/clock/MKV43F15/fsl_clock_MKV43F15.c | 765 ----- .../system/src/clock/MKV43F15/fsl_clock_MKV43F15.h | 1267 -------- .../system/src/clock/MKV44F15/fsl_clock_MKV44F15.c | 765 ----- .../system/src/clock/MKV44F15/fsl_clock_MKV44F15.h | 1267 -------- .../system/src/clock/MKV45F15/fsl_clock_MKV45F15.c | 765 ----- .../system/src/clock/MKV45F15/fsl_clock_MKV45F15.h | 1267 -------- .../system/src/clock/MKV46F15/fsl_clock_MKV46F15.c | 765 ----- .../system/src/clock/MKV46F15/fsl_clock_MKV46F15.h | 1267 -------- .../system/src/clock/MKW01Z4/fsl_clock_MKW01Z4.c | 1012 ------- .../system/src/clock/MKW01Z4/fsl_clock_MKW01Z4.h | 1236 -------- .../system/src/clock/MKW21D5/fsl_clock_MKW21D5.c | 861 ------ .../system/src/clock/MKW21D5/fsl_clock_MKW21D5.h | 1436 ---------- .../system/src/clock/MKW22D5/fsl_clock_MKW22D5.c | 891 ------ .../system/src/clock/MKW22D5/fsl_clock_MKW22D5.h | 1460 ---------- .../system/src/clock/MKW24D5/fsl_clock_MKW24D5.c | 891 ------ .../system/src/clock/MKW24D5/fsl_clock_MKW24D5.h | 1460 ---------- 213 files changed, 257025 deletions(-) mode change 100755 => 100644 KSDK_1.2.0/lib/ksdk_platform_lib/armgcc/KL27Z4/CMakeLists.txt delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK02F12810/fsl_sim_hal_MK02F12810.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK02F12810/fsl_sim_hal_MK02F12810.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK10D10/fsl_sim_hal_MK10D10.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK10D10/fsl_sim_hal_MK10D10.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK11DA5/fsl_sim_hal_MK11DA5.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK11DA5/fsl_sim_hal_MK11DA5.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK20D10/fsl_sim_hal_MK20D10.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK20D10/fsl_sim_hal_MK20D10.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK21DA5/fsl_sim_hal_MK21DA5.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK21DA5/fsl_sim_hal_MK21DA5.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK21FA12/fsl_sim_hal_MK21FA12.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK21FA12/fsl_sim_hal_MK21FA12.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK22F12810/fsl_sim_hal_MK22F12810.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK22F12810/fsl_sim_hal_MK22F12810.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK22F25612/fsl_sim_hal_MK22F25612.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK22F25612/fsl_sim_hal_MK22F25612.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK22F51212/fsl_sim_hal_MK22F51212.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK22F51212/fsl_sim_hal_MK22F51212.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK24F12/fsl_sim_hal_MK24F12.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK24F12/fsl_sim_hal_MK24F12.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK24F25612/fsl_sim_hal_MK24F25612.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK24F25612/fsl_sim_hal_MK24F25612.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK26F18/fsl_sim_hal_MK26F18.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK26F18/fsl_sim_hal_MK26F18.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK30D10/fsl_sim_hal_MK30D10.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK30D10/fsl_sim_hal_MK30D10.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK40D10/fsl_sim_hal_MK40D10.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK40D10/fsl_sim_hal_MK40D10.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK50D10/fsl_sim_hal_MK50D10.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK50D10/fsl_sim_hal_MK50D10.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK51D10/fsl_sim_hal_MK51D10.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK51D10/fsl_sim_hal_MK51D10.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK52D10/fsl_sim_hal_MK52D10.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK52D10/fsl_sim_hal_MK52D10.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK53D10/fsl_sim_hal_MK53D10.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK53D10/fsl_sim_hal_MK53D10.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK60D10/fsl_sim_hal_MK60D10.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK60D10/fsl_sim_hal_MK60D10.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK63F12/fsl_sim_hal_MK63F12.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK63F12/fsl_sim_hal_MK63F12.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK64F12/fsl_sim_hal_MK64F12.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK64F12/fsl_sim_hal_MK64F12.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK65F18/fsl_sim_hal_MK65F18.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK65F18/fsl_sim_hal_MK65F18.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MK66F18/fsl_sim_hal_MK66F18.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MK66F18/fsl_sim_hal_MK66F18.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKL02Z4/fsl_sim_hal_MKL02Z4.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKL02Z4/fsl_sim_hal_MKL02Z4.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKL03Z4/fsl_sim_hal_MKL03Z4.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKL03Z4/fsl_sim_hal_MKL03Z4.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKL14Z4/fsl_sim_hal_MKL14Z4.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKL14Z4/fsl_sim_hal_MKL14Z4.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKL15Z4/fsl_sim_hal_MKL15Z4.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKL15Z4/fsl_sim_hal_MKL15Z4.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKL16Z4/fsl_sim_hal_MKL16Z4.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKL16Z4/fsl_sim_hal_MKL16Z4.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKL17Z4/fsl_sim_hal_MKL17Z4.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKL17Z4/fsl_sim_hal_MKL17Z4.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKL17Z644/fsl_sim_hal_MKL17Z644.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKL17Z644/fsl_sim_hal_MKL17Z644.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKL24Z4/fsl_sim_hal_MKL24Z4.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKL24Z4/fsl_sim_hal_MKL24Z4.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKL25Z4/fsl_sim_hal_MKL25Z4.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKL25Z4/fsl_sim_hal_MKL25Z4.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKL26Z4/fsl_sim_hal_MKL26Z4.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKL26Z4/fsl_sim_hal_MKL26Z4.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKL27Z644/fsl_sim_hal_MKL27Z644.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKL27Z644/fsl_sim_hal_MKL27Z644.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKL33Z4/fsl_sim_hal_MKL33Z4.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKL33Z4/fsl_sim_hal_MKL33Z4.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKL34Z4/fsl_sim_hal_MKL34Z4.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKL34Z4/fsl_sim_hal_MKL34Z4.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKL36Z4/fsl_sim_hal_MKL36Z4.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKL36Z4/fsl_sim_hal_MKL36Z4.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKL43Z4/fsl_sim_hal_MKL43Z4.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKL43Z4/fsl_sim_hal_MKL43Z4.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKL46Z4/fsl_sim_hal_MKL46Z4.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKL46Z4/fsl_sim_hal_MKL46Z4.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKV10Z7/fsl_sim_hal_MKV10Z7.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKV10Z7/fsl_sim_hal_MKV10Z7.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKV30F12810/fsl_sim_hal_MKV30F12810.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKV30F12810/fsl_sim_hal_MKV30F12810.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKV31F12810/fsl_sim_hal_MKV31F12810.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKV31F12810/fsl_sim_hal_MKV31F12810.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKV31F25612/fsl_sim_hal_MKV31F25612.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKV31F25612/fsl_sim_hal_MKV31F25612.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKV31F51212/fsl_sim_hal_MKV31F51212.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKV31F51212/fsl_sim_hal_MKV31F51212.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKV40F15/fsl_sim_hal_MKV40F15.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKV40F15/fsl_sim_hal_MKV40F15.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKV43F15/fsl_sim_hal_MKV43F15.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKV43F15/fsl_sim_hal_MKV43F15.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKV44F15/fsl_sim_hal_MKV44F15.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKV44F15/fsl_sim_hal_MKV44F15.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKV45F15/fsl_sim_hal_MKV45F15.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKV45F15/fsl_sim_hal_MKV45F15.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKV46F15/fsl_sim_hal_MKV46F15.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKV46F15/fsl_sim_hal_MKV46F15.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKW01Z4/fsl_sim_hal_MKW01Z4.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKW01Z4/fsl_sim_hal_MKW01Z4.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKW21D5/fsl_sim_hal_MKW21D5.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKW21D5/fsl_sim_hal_MKW21D5.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKW22D5/fsl_sim_hal_MKW22D5.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKW22D5/fsl_sim_hal_MKW22D5.h delete mode 100755 KSDK_1.2.0/platform/hal/src/sim/MKW24D5/fsl_sim_hal_MKW24D5.c delete mode 100644 KSDK_1.2.0/platform/hal/src/sim/MKW24D5/fsl_sim_hal_MKW24D5.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK02F12810/fsl_clock_MK02F12810.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK02F12810/fsl_clock_MK02F12810.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK10D10/fsl_clock_MK10D10.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK10D10/fsl_clock_MK10D10.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK11DA5/fsl_clock_MK11DA5.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK11DA5/fsl_clock_MK11DA5.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK20D10/fsl_clock_MK20D10.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK20D10/fsl_clock_MK20D10.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK21DA5/fsl_clock_MK21DA5.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK21DA5/fsl_clock_MK21DA5.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK21FA12/fsl_clock_MK21FA12.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK21FA12/fsl_clock_MK21FA12.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK22F12810/fsl_clock_MK22F12810.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK22F12810/fsl_clock_MK22F12810.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK22F25612/fsl_clock_MK22F25612.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK22F25612/fsl_clock_MK22F25612.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK22F51212/fsl_clock_MK22F51212.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK22F51212/fsl_clock_MK22F51212.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK24F12/fsl_clock_MK24F12.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK24F12/fsl_clock_MK24F12.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK24F25612/fsl_clock_MK24F25612.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK24F25612/fsl_clock_MK24F25612.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK26F18/fsl_clock_MK26F18.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK26F18/fsl_clock_MK26F18.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK30D10/fsl_clock_MK30D10.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK30D10/fsl_clock_MK30D10.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK40D10/fsl_clock_MK40D10.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK40D10/fsl_clock_MK40D10.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK50D10/fsl_clock_MK50D10.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK50D10/fsl_clock_MK50D10.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK51D10/fsl_clock_MK51D10.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK51D10/fsl_clock_MK51D10.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK52D10/fsl_clock_MK52D10.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK52D10/fsl_clock_MK52D10.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK53D10/fsl_clock_MK53D10.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK53D10/fsl_clock_MK53D10.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK60D10/fsl_clock_MK60D10.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK60D10/fsl_clock_MK60D10.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK63F12/fsl_clock_MK63F12.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK63F12/fsl_clock_MK63F12.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK64F12/fsl_clock_MK64F12.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK64F12/fsl_clock_MK64F12.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK65F18/fsl_clock_MK65F18.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK65F18/fsl_clock_MK65F18.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MK66F18/fsl_clock_MK66F18.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MK66F18/fsl_clock_MK66F18.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKL02Z4/fsl_clock_MKL02Z4.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKL02Z4/fsl_clock_MKL02Z4.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKL03Z4/fsl_clock_MKL03Z4.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKL03Z4/fsl_clock_MKL03Z4.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKL14Z4/fsl_clock_MKL14Z4.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKL14Z4/fsl_clock_MKL14Z4.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKL15Z4/fsl_clock_MKL15Z4.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKL15Z4/fsl_clock_MKL15Z4.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKL16Z4/fsl_clock_MKL16Z4.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKL16Z4/fsl_clock_MKL16Z4.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKL17Z4/fsl_clock_MKL17Z4.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKL17Z4/fsl_clock_MKL17Z4.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKL17Z644/fsl_clock_MKL17Z644.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKL17Z644/fsl_clock_MKL17Z644.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKL24Z4/fsl_clock_MKL24Z4.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKL24Z4/fsl_clock_MKL24Z4.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKL25Z4/fsl_clock_MKL25Z4.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKL25Z4/fsl_clock_MKL25Z4.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKL26Z4/fsl_clock_MKL26Z4.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKL26Z4/fsl_clock_MKL26Z4.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKL27Z644/fsl_clock_MKL27Z644.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKL27Z644/fsl_clock_MKL27Z644.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKL33Z4/fsl_clock_MKL33Z4.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKL33Z4/fsl_clock_MKL33Z4.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKL34Z4/fsl_clock_MKL34Z4.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKL34Z4/fsl_clock_MKL34Z4.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKL36Z4/fsl_clock_MKL36Z4.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKL36Z4/fsl_clock_MKL36Z4.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKL43Z4/fsl_clock_MKL43Z4.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKL43Z4/fsl_clock_MKL43Z4.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKL46Z4/fsl_clock_MKL46Z4.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKL46Z4/fsl_clock_MKL46Z4.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKV10Z7/fsl_clock_MKV10Z7.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKV10Z7/fsl_clock_MKV10Z7.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKV30F12810/fsl_clock_MKV30F12810.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKV30F12810/fsl_clock_MKV30F12810.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKV31F12810/fsl_clock_MKV31F12810.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKV31F12810/fsl_clock_MKV31F12810.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKV31F25612/fsl_clock_MKV31F25612.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKV31F25612/fsl_clock_MKV31F25612.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKV31F51212/fsl_clock_MKV31F51212.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKV31F51212/fsl_clock_MKV31F51212.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKV40F15/fsl_clock_MKV40F15.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKV40F15/fsl_clock_MKV40F15.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKV43F15/fsl_clock_MKV43F15.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKV43F15/fsl_clock_MKV43F15.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKV44F15/fsl_clock_MKV44F15.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKV44F15/fsl_clock_MKV44F15.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKV45F15/fsl_clock_MKV45F15.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKV45F15/fsl_clock_MKV45F15.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKV46F15/fsl_clock_MKV46F15.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKV46F15/fsl_clock_MKV46F15.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKW01Z4/fsl_clock_MKW01Z4.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKW01Z4/fsl_clock_MKW01Z4.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKW21D5/fsl_clock_MKW21D5.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKW21D5/fsl_clock_MKW21D5.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKW22D5/fsl_clock_MKW22D5.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKW22D5/fsl_clock_MKW22D5.h delete mode 100755 KSDK_1.2.0/platform/system/src/clock/MKW24D5/fsl_clock_MKW24D5.c delete mode 100644 KSDK_1.2.0/platform/system/src/clock/MKW24D5/fsl_clock_MKW24D5.h diff --git a/KSDK_1.2.0/lib/ksdk_platform_lib/armgcc/KL27Z4/CMakeLists.txt b/KSDK_1.2.0/lib/ksdk_platform_lib/armgcc/KL27Z4/CMakeLists.txt old mode 100755 new mode 100644 diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK02F12810/fsl_sim_hal_MK02F12810.c b/KSDK_1.2.0/platform/hal/src/sim/MK02F12810/fsl_sim_hal_MK02F12810.c deleted file mode 100755 index 18d5cbf..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK02F12810/fsl_sim_hal_MK02F12810.c +++ /dev/null @@ -1,762 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM2CH1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - case 1: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - - - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - SIM_BWR_SOPT4_FTM0FLT0(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0FLT1(base, select); - break; - default: - break; - } - break; - case 1: - SIM_BWR_SOPT4_FTM1FLT0(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2FLT0(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault) -{ - sim_ftm_flt_sel_t retValue = (sim_ftm_flt_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT0(base); - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT1(base); - break; - default: - break; - } - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM1FLT0(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM2FLT0(base); - break; - default: - break; - } - - return retValue; -} - -/* Macro for FTMxOCHySRC. */ -#define FTM_CH_OUT_SRC_MASK(instance, channel) \ - (1U << (((instance)>>1U) + channel + 16U)) - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChOutSrcMode - * Description : FlexTimer x channel y output source select setting. - * This function will select FlexTimer x channel y output source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_out_src_t select) -{ - assert (0U==instance); - assert (6U>channel); - - if (kSimFtmChOutSrc0 == select) - { - SIM_CLR_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } - else - { - SIM_SET_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChOutSrcMode - * Description : Get FlexTimer x channel y output source select setting - * This function will get FlexTimer x channel y output source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_out_src_t SIM_HAL_GetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - assert (0U==instance); - assert (6U>channel); - return (sim_ftm_ch_out_src_t) - (SIM_RD_SOPT8(base) & FTM_CH_OUT_SRC_MASK(instance, channel)); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmSyncCmd - * Description : Set FTMxSYNCBIT - * This function sets FlexTimer x hardware trigger 0 software synchronization. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmSyncCmd(SIM_Type * base, uint32_t instance, bool sync) -{ - assert (instance < FTM_INSTANCE_COUNT); - if (sync) - { - SIM_SET_SOPT8(base, (1U< -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfDiv - * Description : Gets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} -#endif - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV3(outdiv3); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = SIM_BRD_CLKDIV1_OUTDIV3(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - SIM_BWR_SOPT4_FTM0FLT0(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0FLT1(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM0FLT2(base, select); - break; - default: - break; - } - break; - case 1: - SIM_BWR_SOPT4_FTM1FLT0(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2FLT0(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault) -{ - sim_ftm_flt_sel_t retValue = (sim_ftm_flt_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT0(base); - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT1(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT2(base); - break; - default: - break; - } - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM1FLT0(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM2FLT0(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK10D10/fsl_sim_hal_MK10D10.h b/KSDK_1.2.0/platform/hal/src/sim/MK10D10/fsl_sim_hal_MK10D10.h deleted file mode 100644 index 958e250..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK10D10/fsl_sim_hal_MK10D10.h +++ /dev/null @@ -1,1731 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_K10D10_H__) -#define __FSL_SIM_HAL_K10D10_H__ - - -/*! - * @addtogroup sim_hal_k10d10 - * @{ - */ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief WDOG clock source select */ -typedef enum _clock_wdog_src_t -{ - kClockWdogSrcLpoClk, /*!< LPO */ - kClockWdogSrcAltClk /*!< Alternative clock, for K10D10 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_wdog_src_k10d10_t; -#else -} clock_wdog_src_t; -#endif - -/*! @brief Debug trace clock source select */ -typedef enum _clock_trace_src_t -{ - kClockTraceSrcMcgoutClk, /*!< MCG out clock */ - kClockTraceSrcCoreClk /*!< core clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_trace_src_k10d10_t; -#else -} clock_trace_src_t; -#endif - -/*! @brief PORTx digital input filter clock source select */ -typedef enum _clock_port_filter_src_t -{ - kClockPortFilterSrcBusClk, /*!< Bus clock */ - kClockPortFilterSrcLpoClk /*!< LPO */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_port_filter_src_k10d10_t; -#else -} clock_port_filter_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG IRC clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_k10d10_t; -#else -} clock_lptmr_src_t; -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! @brief SIM timestamp clock source */ -typedef enum _clock_time_src -{ - kClockTimeSrcCoreSysClk, /*!< Core/system clock */ - kClockTimeSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTimeSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTimeSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_time_src_k10d10_t; -#else -} clock_time_src_t; -#endif -#endif // FSL_FEATURE_SOC_ENET_COUNT - -/*! @brief SIM RMII clock source */ -typedef enum _clock_rmii_src -{ - kClockRmiiSrcExtalClk, /*!< EXTAL Clock */ - kClockRmiiSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rmii_src_k10d10_t; -#else -} clock_rmii_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcPllFllSel, /*!< Clock divider USB FS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_k10d10_t; -#else -} clock_usbfs_src_t; -#endif -#endif // FSL_FEATURE_SOC_USB_COUNT - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*! @brief FLEXCAN clock source select */ -typedef enum _clock_flexcan_src_t -{ - kClockFlexcanSrcOsc0erClk, /*!< OSCERCLK */ - kClockFlexcanSrcBusClk /*!< Bus clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_flexcan_src_k10d10_t; -#else -} clock_flexcan_src_t; -#endif -#endif // FSL_FEATURE_SOC_FLEXCAN_COUNT - -/*! @brief SDHC clock source */ -typedef enum _clock_sdhc_src -{ - kClockSdhcSrcCoreSysClk, /*!< Core/system clock */ - kClockSdhcSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockSdhcSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockSdhcSrcExt /*!< External bypass clock (SDHC0_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sdhc_src_k10d10_t; -#else -} clock_sdhc_src_t; -#endif - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_k10d10_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief TSI Active Mode clock source */ -typedef enum _clock_tsi_active_mode_src -{ - kClockTsiActiveSrcBusClk, /*!< Bus clock */ - kClockTsiActiveSrcMcgIrClk, /*!< MCG IRC clock */ - kClockTsiActiveSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tsi_active_mode_src_k10d10_t; -#else -} clock_tsi_active_mode_src_t; -#endif - -/*! @brief TSI Low-power Mode clock source */ -typedef enum _clock_tsi_lp_mode_src -{ - kClockTsiLpSrcLpoClk, /*!< LPO clock */ - kClockTsiLpSrcEr32kClk /*!< ERCLK32K clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tsi_lp_mode_src_k10d10_t; -#else -} clock_tsi_lp_mode_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll = 0U, /*!< Fll clock */ - kClockPllFllSelPll = 1U, /*!< Pll0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_k10d10_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_k10d10_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlexbusClk = 0U, /*!< Flexbus clock */ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCG out clock */ - kClockClkoutSelRtc32kClk = 5U, /*!< RTC 32k clock */ - kClockClkoutSelOsc0erClk = 6U /*!< OSCERCLK0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_k10d10_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz /*!< 32kHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_k10d10_t; -#else -} clock_rtcout_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_k10d10_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_k10d10_t; -#else -} sim_usbvstby_mode_t; -#endif -#endif // FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_k10d10_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /*!< High speed comparator 0 output */ - kSimAdcTrgSelHighSpeedComp1 = 2U, /*!< High speed comparator 1 output */ - kSimAdcTrgSelHighSpeedComp2 = 3U, /*!< High speed comparator 2 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelPit2 = 6U, /*!< PIT trigger 2 */ - kSimAdcTrgSelPit3 = 7U, /*!< PIT trigger 3 */ - kSimAdcTrgSelFtm0 = 8U, /*!< FTM0 trigger */ - kSimAdcTrgSelFtm1 = 9U, /*!< FTM1 trigger */ - kSimAdcTrgSelFtm2 = 10U, /*!< FTM2 trigger */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_k10d10_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ - kSimUartRxsrcCmp1, /*!< CMP1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_k10d10_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcFtm1, /*!< UARTx_TX pin modulated with FTM1 channel 0 output */ - kSimUartTxsrcFtm2 /*!< UARTx_TX pin modulated with FTM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_k10d10_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM FlexTimer x trigger y select */ -typedef enum _sim_ftm_trg_src -{ - kSimFtmTrgSrc0, /*!< FlexTimer x trigger y select 0 */ - kSimFtmTrgSrc1 /*!< FlexTimer x trigger y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_trg_src_k10d10_t; -#else -} sim_ftm_trg_src_t; -#endif - -/*! @brief SIM FlexTimer external clock select */ -typedef enum _sim_ftm_clk_sel -{ - kSimFtmClkSel0, /*!< FTM CLKIN0 pin. */ - kSimFtmClkSel1 /*!< FTM CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_clk_sel_k10d10_t; -#else -} sim_ftm_clk_sel_t; -#endif - -/*! @brief SIM FlexTimer x channel y input capture source select */ -typedef enum _sim_ftm_ch_src -{ - kSimFtmChSrc0, /*!< FlexTimer x channel y input capture source 0. */ - kSimFtmChSrc1, /*!< FlexTimer x channel y input capture source 1. */ - kSimFtmChSrc2, /*!< FlexTimer x channel y input capture source 2. */ - kSimFtmChSrc3 /*!< FlexTimer x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_ch_src_k10d10_t; -#else -} sim_ftm_ch_src_t; -#endif - -/*! @brief SIM FlexTimer x Fault y select */ -typedef enum _sim_ftm_flt_sel -{ - kSimFtmFltSel0, /*!< FlexTimer x fault y select 0 */ - kSimFtmFltSel1 /*!< FlexTimer x fault y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_flt_sel_k10d10_t; -#else -} sim_ftm_flt_sel_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_k10d10_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1 /*!< CMP0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_k10d10_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM CMT/UART pad drive strength */ -typedef enum _sim_cmtuartpad_strengh -{ - kSimCmtuartSinglePad, /*!< Single-pad drive strength for CMT IRO or UART0_TXD */ - kSimCmtuartDualPad /*!< Dual-pad drive strength for CMT IRO or UART0_TXD */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_cmtuartpad_strengh_k10d10_t; -#else -} sim_cmtuartpad_strengh_t; -#endif - -/*! @brief SIM PTD7 pad drive strength */ -typedef enum _sim_ptd7pad_strengh -{ - kSimPtd7padSinglePad, /*!< Single-pad drive strength for PTD7 */ - kSimPtd7padDualPad /*!< Dual-pad drive strength for PTD7 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ptd7pad_strengh_k10d10_t; -#else -} sim_ptd7pad_strengh_t; -#endif - -/*! @brief SIM FlexBus security level */ -typedef enum _sim_flexbus_security_level -{ - kSimFbslLevel0, /*!< FlexBus security level 0. */ - kSimFbslLevel1, /*!< FlexBus security level 1. */ - kSimFbslLevel2, /*!< FlexBus security level 2. */ - kSimFbslLevel3, /*!< FlexBus security level 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_flexbus_security_level_k10d10_t; -#else -} sim_flexbus_security_level_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateUart4 = FSL_SIM_SCGC_BIT(1U, 10U), - kSimClockGateUart5 = FSL_SIM_SCGC_BIT(1U, 11U), -#if FSL_FEATURE_SOC_OPAMP_COUNT - kSimClockGateOpamp = FSL_SIM_SCGC_BIT(1U, 21U), -#endif -#if FSL_FEATURE_SOC_TRIAMP_COUNT - kSimClockGateTriamp = FSL_SIM_SCGC_BIT(1U, 24U), -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT - kSimClockGateEnet0 = FSL_SIM_SCGC_BIT(2U, 0U), -#endif - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(2U, 12U), - kSimClockGateDac1 = FSL_SIM_SCGC_BIT(2U, 13U), - -#if FSL_FEATURE_SOC_RNG_COUNT - kSimClockGateRnga0 = FSL_SIM_SCGC_BIT(3U, 0U), -#endif -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - kSimClockGateFlexcan1 = FSL_SIM_SCGC_BIT(3U, 4U), -#endif - kSimClockGateSpi2 = FSL_SIM_SCGC_BIT(3U, 12U), - kSimClockGateSdhc0 = FSL_SIM_SCGC_BIT(3U, 17U), - kSimClockGateFtm2 = FSL_SIM_SCGC_BIT(3U, 24U), - kSimClockGateAdc1 = FSL_SIM_SCGC_BIT(3U, 27U), -#if FSL_FEATURE_SOC_LCD_COUNT - kSimClockGateSlcd0 = FSL_SIM_SCGC_BIT(3U, 30U), -#endif - - kSimClockGateEwm0 = FSL_SIM_SCGC_BIT(4U, 1U), - kSimClockGateCmt0 = FSL_SIM_SCGC_BIT(4U, 2U), - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUart3 = FSL_SIM_SCGC_BIT(4U, 13U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), -#endif - kSimClockGateCmp = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateLlwu0 = FSL_SIM_SCGC_BIT(4U, 28U), - - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGateTsi0 = FSL_SIM_SCGC_BIT(5U, 5U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - kSimClockGateFlexcan0 = FSL_SIM_SCGC_BIT(6U, 4U), -#endif - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(6U, 12U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(6U, 13U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbdcd0 = FSL_SIM_SCGC_BIT(6U, 21U), -#endif - kSimClockGatePdb0 = FSL_SIM_SCGC_BIT(6U, 22U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateFtm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateFtm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - - kSimClockGateFlexbus0 = FSL_SIM_SCGC_BIT(7U, 0U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 1U), - kSimClockGateMpu0 = FSL_SIM_SCGC_BIT(7U, 2U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_k10d10_t; -#else -} sim_clock_gate_name_t; -#endif - -/*! @} */ -/******************************************************************************* - * API - ******************************************************************************/ - - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetSdhcSrc(SIM_Type * base, - uint32_t instance, - clock_sdhc_src_t setting) -{ - SIM_BWR_SOPT2_SDHCSRC(base, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_HAL_GetSdhcSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_sdhc_src_t)SIM_BRD_SOPT2_SDHCSRC(base); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTimeSrc(SIM_Type * base, - uint32_t instance, - clock_time_src_t setting) -{ - SIM_BWR_SOPT2_TIMESRC(base, setting); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_time_src_t CLOCK_HAL_GetTimeSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_time_src_t)SIM_BRD_SOPT2_TIMESRC(base); -} - -/*! - * @brief Set the Ethernet RMII interface clock source selection. - * - * This function sets the Ethernet RMII interface clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRmiiSrc(SIM_Type * base, - uint32_t instance, - clock_rmii_src_t setting) -{ - SIM_BWR_SOPT2_RMIISRC(base, setting); -} - -/*! - * @brief Get the Ethernet RMII interface clock source selection. - * - * This function gets the Ethernet RMII interface clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_rmii_src_t CLOCK_HAL_GetRmiiSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_rmii_src_t)SIM_BRD_SOPT2_RMIISRC(base); -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} -#endif - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set debug trace clock selection. - * - * This function sets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTraceClkSrc(SIM_Type * base, clock_trace_src_t setting) -{ - SIM_BWR_SOPT2_TRACECLKSEL(base, setting); -} - -/*! - * @brief Get debug trace clock selection. - * - * This function gets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_trace_src_t CLOCK_HAL_GetTraceClkSrc(SIM_Type * base) -{ - return (clock_trace_src_t)SIM_BRD_SOPT2_TRACECLKSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV2. - * - * This function sets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv2(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV2(base, setting); -} - -/*! - * @brief Get OUTDIV2. - * - * This function gets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv2(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV2(base); -} - -/*! - * @brief Set OUTDIV3. - * - * This function sets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv3(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV3(base, setting); -} - -/*! - * @brief Get OUTDIV3. - * - * This function gets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv3(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV3(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac); - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac); -#endif - -/*! - * @brief Gets RAM size. - * - * This function gets the RAM size. The field specifies the amount of system RAM - * available on the device. - * - * @param base Base address for current SIM instance. - * @return size RAM size on the device - */ -static inline uint32_t SIM_HAL_GetRamSize(SIM_Type * base) -{ - return SIM_BRD_SOPT1_RAMSIZE(base); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif - -/*! - * @brief Sets the PTD7 pad drive strength setting. - * - * This function controls the output drive strength of the PTD7 pin by selecting - * either one or two pads to drive it. - * - * @param base Base address for current SIM instance. - * @param setting PTD7 pad drive strength setting - * - 0: Single-pad drive strength for PTD7. - * - 1: Double pad drive strength for PTD7. - */ -static inline void SIM_HAL_SetPtd7PadDriveStrengthMode(SIM_Type * base, - sim_ptd7pad_strengh_t setting) -{ - SIM_BWR_SOPT2_PTD7PAD(base, setting); -} - -/*! - * @brief Gets the PTD7 pad drive strength setting. - * - * This function gets the PTD7 pad drive strength setting. - * - * @param base Base address for current SIM instance. - * @return setting PTD7 pad drive strength setting - */ -static inline sim_ptd7pad_strengh_t SIM_HAL_GetPtd7PadDriveStrengthMode(SIM_Type * base) -{ - return (sim_ptd7pad_strengh_t)SIM_BRD_SOPT2_PTD7PAD(base); -} - -/*! - * @brief Sets the FlexBus security level setting. - * - * This function sets the FlexBus security level setting. If the security is enabled, - * this field affects which CPU operations can access the off-chip via the FlexBus - * and DDR controller interfaces. This field has no effect if the security is not enabled. - * - * @param base Base address for current SIM instance. - * @param setting FlexBus security level setting - * - 00: All off-chip accesses (op code and data) via the FlexBus and - * DDR controller are disallowed. - * - 10: Off-chip op code accesses are disallowed. Data accesses are - * allowed. - * - 11: Off-chip op code accesses and data accesses are allowed. - */ -static inline void SIM_HAL_SetFlexbusSecurityLevelMode(SIM_Type * base, - sim_flexbus_security_level_t setting) -{ - SIM_BWR_SOPT2_FBSL(base, setting); -} - -/*! - * @brief Gets the FlexBus security level setting. - * - * This function gets the FlexBus security level setting. - * - * @param base Base address for current SIM instance. - * @return setting FlexBus security level setting - */ -static inline sim_flexbus_security_level_t SIM_HAL_GetFlexbusSecurityLevelMode(SIM_Type * base) -{ - return (sim_flexbus_security_level_t)SIM_BRD_SOPT2_FBSL(base); -} - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select); - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select); - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the FlexTimer x hardware trigger y source select setting. - * - * This function selects the source of FTMx hardware trigger y. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @param select FlexTimer x hardware trigger y - * - 0: Pre-trigger A selected for ADCx. - * - 1: Pre-trigger B selected for ADCx. - */ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select); - -/*! - * @brief Gets the FlexTimer x hardware trigger y source select setting. - * - * This function gets the FlexTimer x hardware trigger y source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @return select FlexTimer x hardware trigger y source select setting - */ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger); - -/*! - * @brief Sets the FlexTimer x external clock pin select setting. - * - * This function selects the source of FTMx external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select FTMx external clock pin select - * - 0: FTMx external clock driven by FTM CLKIN0 pin. - * - 1: FTMx external clock driven by FTM CLKIN1 pin. - */ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select); - -/*! - * @brief Gets the FlexTimer x external clock pin select setting. - * - * This function gets the FlexTimer x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select FlexTimer x external clock pin select setting - */ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the FlexTimer x channel y input capture source select setting. - * - * This function selects the FlexTimer x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y input capture source - */ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y input capture source select setting. - * - * This function gets the FlexTimer x channel y input capture - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y input capture source select setting - */ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Sets the FlexTimer x fault y select setting. - * - * This function sets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @param select FlexTimer x fault y select setting - * - 0: FlexTimer x fault y select 0. - * - 1: FlexTimer x fault y select 1. - */ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select); - -/*! - * @brief Gets the FlexTimer x fault y select setting. - * - * This function gets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @return select FlexTimer x fault y select setting - */ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault); - -/*! - * @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Fam ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Fam ID - */ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the FlexNVM size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size FlexNVM Size - */ -static inline uint32_t SIM_HAL_GetFlexnvmSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_NVMSIZE(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Gets the EEProm size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the EEProm size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size EEProm Size - */ -static inline uint32_t SIM_HAL_GetEepromSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_EESIZE(base); -} - -/*! - * @brief Gets the FlexNVM partition in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM partition in the Flash Configuration Register1 - * - * @param base Base address for current SIM instance. - * @return setting FlexNVM partition setting - */ -static inline uint32_t SIM_HAL_GetFlexnvmPartition(SIM_Type * base) -{ - return SIM_BRD_FCFG1_DEPART(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -/*! - * @brief Gets the program flash in the Flash Configuration Register 2. - * - * This function gets the program flash maximum block 0 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return status program flash status - */ -static inline uint32_t SIM_HAL_GetProgramFlashCmd(SIM_Type * base) -{ - return SIM_BRD_FCFG2_PFLSH(base); -} - -/*! - * @brief Gets the Swap program flash flag in the Flash Configuration Register 2. - * - * This function gets the Swap program flash flag in the Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return status - Swap program flash flag(Active or Inactive) - */ -static inline bool SIM_HAL_GetSwapProgramFlash(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG2_SWAPPFLSH(base); -} - - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ -/*! @}*/ - - -#endif /* __FSL_SIM_HAL_K10D10_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK11DA5/fsl_sim_hal_MK11DA5.c b/KSDK_1.2.0/platform/hal/src/sim/MK11DA5/fsl_sim_hal_MK11DA5.c deleted file mode 100755 index fb44173..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK11DA5/fsl_sim_hal_MK11DA5.c +++ /dev/null @@ -1,685 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - SIM_BWR_SOPT4_FTM0FLT0(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0FLT1(base, select); - break; - default: - break; - } - break; - case 1: - SIM_BWR_SOPT4_FTM1FLT0(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2FLT0(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault) -{ - sim_ftm_flt_sel_t retValue = (sim_ftm_flt_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT0(base); - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT1(base); - break; - default: - break; - } - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM1FLT0(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM2FLT0(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK11DA5/fsl_sim_hal_MK11DA5.h b/KSDK_1.2.0/platform/hal/src/sim/MK11DA5/fsl_sim_hal_MK11DA5.h deleted file mode 100644 index b24239b..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK11DA5/fsl_sim_hal_MK11DA5.h +++ /dev/null @@ -1,1221 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_K11DA5_H__) -#define __FSL_SIM_HAL_K11DA5_H__ - -/*! @addtogroup sim_hal_k11da50*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief WDOG clock source select */ -typedef enum _clock_wdog_src_t -{ - kClockWdogSrcLpoClk, /* LPO */ - kClockWdogSrcAltClk, /* Alternative clock, for K11DA5 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_wdog_src_k11da5_t; -#else -} clock_wdog_src_t; -#endif - -/*! @brief Debug trace clock source select */ -typedef enum _clock_trace_src_t -{ - kClockTraceSrcMcgoutClk, /*!< MCG out clock */ - kClockTraceSrcCoreClk /*!< core clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_trace_src_k11da5_t; -#else -} clock_trace_src_t; -#endif - -/*! @brief PORTx digital input filter clock source select */ -typedef enum _clock_port_filter_src_t -{ - kClockPortFilterSrcBusClk, /*!< Bus clock */ - kClockPortFilterSrcLpoClk /*!< LPO */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_port_filter_src_k11da5_t; -#else -} clock_port_filter_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG IRC clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_k11da5_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief SIM timestamp clock source */ -typedef enum _clock_time_src -{ - kClockTimeSrcCoreSysClk, /*!< Core/system clock */ - kClockTimeSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTimeSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTimeSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_time_src_k11da5_t; -#else -} clock_time_src_t; -#endif - -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcPllFllSel, /*!< Clock divider USB FS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_k11da5_t; -#else -} clock_usbfs_src_t; -#endif - - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_k11da5_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll = 0U, /*!< Fll clock */ - kClockPllFllSelPll = 1U, /*!< Pll0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_k11da5_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_k11da5_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCG out clock */ - kClockClkoutSelRtc32kClk = 5U, /*!< RTC 32k clock */ - kClockClkoutSelOsc0erClk = 6U /*!< OSCERCLK0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_k11da5_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz /*!< 32kHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_k11da5_t; -#else -} clock_rtcout_src_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_k11da5_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_k11da5_t; -#else -} sim_usbvstby_mode_t; -#endif - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_k11da5_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /*!< High speed comparator 0 output */ - kSimAdcTrgSelHighSpeedComp1 = 2U, /*!< High speed comparator 1 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelPit2 = 6U, /*!< PIT trigger 2 */ - kSimAdcTrgSelPit3 = 7U, /*!< PIT trigger 3 */ - kSimAdcTrgSelFtm0 = 8U, /*!< FTM0 trigger */ - kSimAdcTrgSelFtm1 = 9U, /*!< FTM1 trigger */ - kSimAdcTrgSelFtm2 = 10U, /*!< FTM2 trigger */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_k11da5_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ - kSimUartRxsrcCmp1, /*!< CMP1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_k11da5_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcFtm1, /*!< UARTx_TX pin modulated with FTM1 channel 0 output */ - kSimUartTxsrcFtm2 /*!< UARTx_TX pin modulated with FTM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_k11da5_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM FlexTimer x trigger y select */ -typedef enum _sim_ftm_trg_src -{ - kSimFtmTrgSrc0, /*!< FlexTimer x trigger y select 0 */ - kSimFtmTrgSrc1 /*!< FlexTimer x trigger y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_trg_src_k11d5_t; -#else -} sim_ftm_trg_src_t; -#endif - -/*! @brief SIM FlexTimer external clock select */ -typedef enum _sim_ftm_clk_sel -{ - kSimFtmClkSel0, /*!< FTM CLKIN0 pin. */ - kSimFtmClkSel1 /*!< FTM CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_clk_sel_k11da5_t; -#else -} sim_ftm_clk_sel_t; -#endif - -/*! @brief SIM FlexTimer x channel y input capture source select */ -typedef enum _sim_ftm_ch_src -{ - kSimFtmChSrc0, /*!< FlexTimer x channel y input capture source 0. */ - kSimFtmChSrc1, /*!< FlexTimer x channel y input capture source 1. */ - kSimFtmChSrc2, /*!< FlexTimer x channel y input capture source 2. */ - kSimFtmChSrc3 /*!< FlexTimer x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_ch_src_k11da5_t; -#else -} sim_ftm_ch_src_t; -#endif - -/*! @brief SIM FlexTimer x Fault y select */ -typedef enum _sim_ftm_flt_sel -{ - kSimFtmFltSel0, /*!< FlexTimer x fault y select 0 */ - kSimFtmFltSel1 /*!< FlexTimer x fault y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_flt_sel_k11da5_t; -#else -} sim_ftm_flt_sel_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_k11da5_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1 /*!< CMP0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_k11da5_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM CMT/UART pad drive strength */ -typedef enum _sim_cmtuartpad_strengh -{ - kSimCmtuartSinglePad, /*!< Single-pad drive strength for CMT IRO or UART0_TXD */ - kSimCmtuartDualPad /*!< Dual-pad drive strength for CMT IRO or UART0_TXD */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_cmtuartpad_strengh_k11da5_t; -#else -} sim_cmtuartpad_strengh_t; -#endif - -/*! @brief SIM PTD7 pad drive strength */ -typedef enum _sim_ptd7pad_strengh -{ - kSimPtd7padSinglePad, /*!< Single-pad drive strength for PTD7 */ - kSimPtd7padDualPad /*!< Dual-pad drive strength for PTD7 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ptd7pad_strengh_k11da5_t; -#else -} sim_ptd7pad_strengh_t; -#endif - - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateEwm0 = FSL_SIM_SCGC_BIT(4U, 1U), - kSimClockGateCmt0 = FSL_SIM_SCGC_BIT(4U, 2U), - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUart3 = FSL_SIM_SCGC_BIT(4U, 13U), - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), - kSimClockGateCmp = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateRnga0 = FSL_SIM_SCGC_BIT(6U, 9U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(6U, 12U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(6U, 13U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), - kSimClockGateUsbdcd0 = FSL_SIM_SCGC_BIT(6U, 21U), - kSimClockGatePdb0 = FSL_SIM_SCGC_BIT(6U, 22U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateFtm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateFtm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateFtm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(6U, 31U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 1U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_k11da5_t; -#else -} sim_clock_gate_name_t; -#endif - - -/*! @} */ -/******************************************************************************* - * API - ******************************************************************************/ - - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set debug trace clock selection. - * - * This function sets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTraceClkSrc(SIM_Type * base, clock_trace_src_t setting) -{ - SIM_BWR_SOPT2_TRACECLKSEL(base, setting); -} - -/*! - * @brief Get debug trace clock selection. - * - * This function gets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_trace_src_t CLOCK_HAL_GetTraceClkSrc(SIM_Type * base) -{ - return (clock_trace_src_t)SIM_BRD_SOPT2_TRACECLKSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV2. - * - * This function sets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv2(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV2(base, setting); -} - -/*! - * @brief Get OUTDIV2. - * - * This function gets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv2(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV2(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac); - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac); - -/*! - * @brief Gets RAM size. - * - * This function gets the RAM size. The field specifies the amount of system RAM - * available on the device. - * - * @param base Base address for current SIM instance. - * @return size RAM size on the device - */ -static inline uint32_t SIM_HAL_GetRamSize(SIM_Type * base) -{ - return SIM_BRD_SOPT1_RAMSIZE(base); -} - -/*! - * @brief Sets the PTD7 pad drive strength setting. - * - * This function controls the output drive strength of the PTD7 pin by selecting - * either one or two pads to drive it. - * - * @param base Base address for current SIM instance. - * @param setting PTD7 pad drive strength setting - * - 0: Single-pad drive strength for PTD7. - * - 1: Double pad drive strength for PTD7. - */ -static inline void SIM_HAL_SetPtd7PadDriveStrengthMode(SIM_Type * base, - sim_ptd7pad_strengh_t setting) -{ - SIM_BWR_SOPT2_PTD7PAD(base, setting); -} - -/*! - * @brief Gets the PTD7 pad drive strength setting. - * - * This function gets the PTD7 pad drive strength setting. - * - * @param base Base address for current SIM instance. - * @return setting PTD7 pad drive strength setting - */ -static inline sim_ptd7pad_strengh_t SIM_HAL_GetPtd7PadDriveStrengthMode(SIM_Type * base) -{ - return (sim_ptd7pad_strengh_t)SIM_BRD_SOPT2_PTD7PAD(base); -} - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select); - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select); - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the FlexTimer x hardware trigger y source select setting. - * - * This function selects the source of FTMx hardware trigger y. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @param select FlexTimer x hardware trigger y - * - 0: Pre-trigger A selected for ADCx. - * - 1: Pre-trigger B selected for ADCx. - */ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select); - -/*! - * @brief Gets the FlexTimer x hardware trigger y source select setting. - * - * This function gets the FlexTimer x hardware trigger y source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @return select FlexTimer x hardware trigger y source select setting - */ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger); - -/*! - * @brief Sets the FlexTimer x external clock pin select setting. - * - * This function selects the source of FTMx external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select FTMx external clock pin select - * - 0: FTMx external clock driven by FTM CLKIN0 pin. - * - 1: FTMx external clock driven by FTM CLKIN1 pin. - */ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select); - -/*! - * @brief Gets the FlexTimer x external clock pin select setting. - * - * This function gets the FlexTimer x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select FlexTimer x external clock pin select setting - */ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the FlexTimer x channel y input capture source select setting. - * - * This function selects the FlexTimer x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y input capture source - */ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y input capture source select setting. - * - * This function gets the FlexTimer x channel y input capture - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y input capture source select setting - */ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Sets the FlexTimer x fault y select setting. - * - * This function sets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @param select FlexTimer x fault y select setting - * - 0: FlexTimer x fault y select 0. - * - 1: FlexTimer x fault y select 1. - */ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select); - -/*! - * @brief Gets the FlexTimer x fault y select setting. - * - * This function gets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @return select FlexTimer x fault y select setting - */ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault); - -/*! - * @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Fam ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Fam ID - */ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the FlexNVM size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size FlexNVM Size - */ -static inline uint32_t SIM_HAL_GetFlexnvmSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_NVMSIZE(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Gets the EEProm size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the EEProm size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size EEProm Size - */ -static inline uint32_t SIM_HAL_GetEepromSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_EESIZE(base); -} - -/*! - * @brief Gets the FlexNVM partition in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM partition in the Flash Configuration Register1 - * - * @param base Base address for current SIM instance. - * @return setting FlexNVM partition setting - */ -static inline uint32_t SIM_HAL_GetFlexnvmPartition(SIM_Type * base) -{ - return SIM_BRD_FCFG1_DEPART(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -/*! - * @brief Gets the program flash in the Flash Configuration Register 2. - * - * This function gets the program flash maximum block 0 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return status program flash status - */ -static inline uint32_t SIM_HAL_GetProgramFlashCmd(SIM_Type * base) -{ - return SIM_BRD_FCFG2_PFLSH(base); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ -/*! @}*/ - - -#endif /* __FSL_SIM_HAL_K11DA5_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK20D10/fsl_sim_hal_MK20D10.c b/KSDK_1.2.0/platform/hal/src/sim/MK20D10/fsl_sim_hal_MK20D10.c deleted file mode 100755 index 46e1ed3..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK20D10/fsl_sim_hal_MK20D10.c +++ /dev/null @@ -1,750 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfDiv - * Description : Gets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} -#endif - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV3(outdiv3); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = SIM_BRD_CLKDIV1_OUTDIV3(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - SIM_BWR_SOPT4_FTM0FLT0(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0FLT1(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM0FLT2(base, select); - break; - default: - break; - } - break; - case 1: - SIM_BWR_SOPT4_FTM1FLT0(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2FLT0(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault) -{ - sim_ftm_flt_sel_t retValue = (sim_ftm_flt_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT0(base); - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT1(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT2(base); - break; - default: - break; - } - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM1FLT0(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM2FLT0(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK20D10/fsl_sim_hal_MK20D10.h b/KSDK_1.2.0/platform/hal/src/sim/MK20D10/fsl_sim_hal_MK20D10.h deleted file mode 100644 index 00eefa3..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK20D10/fsl_sim_hal_MK20D10.h +++ /dev/null @@ -1,1731 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_K20D10_H__) -#define __FSL_SIM_HAL_K20D10_H__ - - -/*! - * @addtogroup sim_hal_k20d10 - * @{ - */ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief WDOG clock source select */ -typedef enum _clock_wdog_src_t -{ - kClockWdogSrcLpoClk, /*!< LPO */ - kClockWdogSrcAltClk /*!< Alternative clock, for K20D10 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_wdog_src_k20d10_t; -#else -} clock_wdog_src_t; -#endif - -/*! @brief Debug trace clock source select */ -typedef enum _clock_trace_src_t -{ - kClockTraceSrcMcgoutClk, /*!< MCG out clock */ - kClockTraceSrcCoreClk /*!< core clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_trace_src_k20d10_t; -#else -} clock_trace_src_t; -#endif - -/*! @brief PORTx digital input filter clock source select */ -typedef enum _clock_port_filter_src_t -{ - kClockPortFilterSrcBusClk, /*!< Bus clock */ - kClockPortFilterSrcLpoClk /*!< LPO */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_port_filter_src_k20d10_t; -#else -} clock_port_filter_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG IRC clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_k20d10_t; -#else -} clock_lptmr_src_t; -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! @brief SIM timestamp clock source */ -typedef enum _clock_time_src -{ - kClockTimeSrcCoreSysClk, /*!< Core/system clock */ - kClockTimeSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTimeSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTimeSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_time_src_k20d10_t; -#else -} clock_time_src_t; -#endif -#endif // FSL_FEATURE_SOC_ENET_COUNT - -/*! @brief SIM RMII clock source */ -typedef enum _clock_rmii_src -{ - kClockRmiiSrcExtalClk, /*!< EXTAL Clock */ - kClockRmiiSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rmii_src_k20d10_t; -#else -} clock_rmii_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcPllFllSel, /*!< Clock divider USB FS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_k20d10_t; -#else -} clock_usbfs_src_t; -#endif -#endif // FSL_FEATURE_SOC_USB_COUNT - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*! @brief FLEXCAN clock source select */ -typedef enum _clock_flexcan_src_t -{ - kClockFlexcanSrcOsc0erClk, /*!< OSCERCLK */ - kClockFlexcanSrcBusClk /*!< Bus clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_flexcan_src_k20d10_t; -#else -} clock_flexcan_src_t; -#endif -#endif // FSL_FEATURE_SOC_FLEXCAN_COUNT - -/*! @brief SDHC clock source */ -typedef enum _clock_sdhc_src -{ - kClockSdhcSrcCoreSysClk, /*!< Core/system clock */ - kClockSdhcSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockSdhcSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockSdhcSrcExt /*!< External bypass clock (SDHC0_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sdhc_src_k20d10_t; -#else -} clock_sdhc_src_t; -#endif - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_k20d10_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief TSI Active Mode clock source */ -typedef enum _clock_tsi_active_mode_src -{ - kClockTsiActiveSrcBusClk, /*!< Bus clock */ - kClockTsiActiveSrcMcgIrClk, /*!< MCG IRC clock */ - kClockTsiActiveSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tsi_active_mode_src_k20d10_t; -#else -} clock_tsi_active_mode_src_t; -#endif - -/*! @brief TSI Low-power Mode clock source */ -typedef enum _clock_tsi_lp_mode_src -{ - kClockTsiLpSrcLpoClk, /*!< LPO clock */ - kClockTsiLpSrcEr32kClk /*!< ERCLK32K clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tsi_lp_mode_src_k20d10_t; -#else -} clock_tsi_lp_mode_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll = 0U, /*!< Fll clock */ - kClockPllFllSelPll = 1U, /*!< Pll0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_k20d10_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_k20d10_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlexbusClk = 0U, /*!< Flexbus clock */ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCG out clock */ - kClockClkoutSelRtc32kClk = 5U, /*!< RTC 32k clock */ - kClockClkoutSelOsc0erClk = 6U /*!< OSCERCLK0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_k20d10_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz /*!< 32kHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_k20d10_t; -#else -} clock_rtcout_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_k20d10_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_k20d10_t; -#else -} sim_usbvstby_mode_t; -#endif -#endif // FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_k20d10_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /*!< High speed comparator 0 output */ - kSimAdcTrgSelHighSpeedComp1 = 2U, /*!< High speed comparator 1 output */ - kSimAdcTrgSelHighSpeedComp2 = 3U, /*!< High speed comparator 2 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelPit2 = 6U, /*!< PIT trigger 2 */ - kSimAdcTrgSelPit3 = 7U, /*!< PIT trigger 3 */ - kSimAdcTrgSelFtm0 = 8U, /*!< FTM0 trigger */ - kSimAdcTrgSelFtm1 = 9U, /*!< FTM1 trigger */ - kSimAdcTrgSelFtm2 = 10U, /*!< FTM2 trigger */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_k20d10_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ - kSimUartRxsrcCmp1, /*!< CMP1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_k20d10_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcFtm1, /*!< UARTx_TX pin modulated with FTM1 channel 0 output */ - kSimUartTxsrcFtm2 /*!< UARTx_TX pin modulated with FTM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_k20d10_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM FlexTimer x trigger y select */ -typedef enum _sim_ftm_trg_src -{ - kSimFtmTrgSrc0, /*!< FlexTimer x trigger y select 0 */ - kSimFtmTrgSrc1 /*!< FlexTimer x trigger y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_trg_src_k20d10_t; -#else -} sim_ftm_trg_src_t; -#endif - -/*! @brief SIM FlexTimer external clock select */ -typedef enum _sim_ftm_clk_sel -{ - kSimFtmClkSel0, /*!< FTM CLKIN0 pin. */ - kSimFtmClkSel1 /*!< FTM CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_clk_sel_k20d10_t; -#else -} sim_ftm_clk_sel_t; -#endif - -/*! @brief SIM FlexTimer x channel y input capture source select */ -typedef enum _sim_ftm_ch_src -{ - kSimFtmChSrc0, /*!< FlexTimer x channel y input capture source 0. */ - kSimFtmChSrc1, /*!< FlexTimer x channel y input capture source 1. */ - kSimFtmChSrc2, /*!< FlexTimer x channel y input capture source 2. */ - kSimFtmChSrc3 /*!< FlexTimer x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_ch_src_k20d10_t; -#else -} sim_ftm_ch_src_t; -#endif - -/*! @brief SIM FlexTimer x Fault y select */ -typedef enum _sim_ftm_flt_sel -{ - kSimFtmFltSel0, /*!< FlexTimer x fault y select 0 */ - kSimFtmFltSel1 /*!< FlexTimer x fault y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_flt_sel_k20d10_t; -#else -} sim_ftm_flt_sel_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_k20d10_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1 /*!< CMP0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_k20d10_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM CMT/UART pad drive strength */ -typedef enum _sim_cmtuartpad_strengh -{ - kSimCmtuartSinglePad, /*!< Single-pad drive strength for CMT IRO or UART0_TXD */ - kSimCmtuartDualPad /*!< Dual-pad drive strength for CMT IRO or UART0_TXD */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_cmtuartpad_strengh_k20d10_t; -#else -} sim_cmtuartpad_strengh_t; -#endif - -/*! @brief SIM PTD7 pad drive strength */ -typedef enum _sim_ptd7pad_strengh -{ - kSimPtd7padSinglePad, /*!< Single-pad drive strength for PTD7 */ - kSimPtd7padDualPad /*!< Dual-pad drive strength for PTD7 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ptd7pad_strengh_k20d10_t; -#else -} sim_ptd7pad_strengh_t; -#endif - -/*! @brief SIM FlexBus security level */ -typedef enum _sim_flexbus_security_level -{ - kSimFbslLevel0, /*!< FlexBus security level 0. */ - kSimFbslLevel1, /*!< FlexBus security level 1. */ - kSimFbslLevel2, /*!< FlexBus security level 2. */ - kSimFbslLevel3, /*!< FlexBus security level 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_flexbus_security_level_k20d10_t; -#else -} sim_flexbus_security_level_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateUart4 = FSL_SIM_SCGC_BIT(1U, 10U), - kSimClockGateUart5 = FSL_SIM_SCGC_BIT(1U, 11U), -#if FSL_FEATURE_SOC_OPAMP_COUNT - kSimClockGateOpamp = FSL_SIM_SCGC_BIT(1U, 21U), -#endif -#if FSL_FEATURE_SOC_TRIAMP_COUNT - kSimClockGateTriamp = FSL_SIM_SCGC_BIT(1U, 24U), -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT - kSimClockGateEnet0 = FSL_SIM_SCGC_BIT(2U, 0U), -#endif - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(2U, 12U), - kSimClockGateDac1 = FSL_SIM_SCGC_BIT(2U, 13U), - -#if FSL_FEATURE_SOC_RNG_COUNT - kSimClockGateRnga0 = FSL_SIM_SCGC_BIT(3U, 0U), -#endif -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - kSimClockGateFlexcan1 = FSL_SIM_SCGC_BIT(3U, 4U), -#endif - kSimClockGateSpi2 = FSL_SIM_SCGC_BIT(3U, 12U), - kSimClockGateSdhc0 = FSL_SIM_SCGC_BIT(3U, 17U), - kSimClockGateFtm2 = FSL_SIM_SCGC_BIT(3U, 24U), - kSimClockGateAdc1 = FSL_SIM_SCGC_BIT(3U, 27U), -#if FSL_FEATURE_SOC_LCD_COUNT - kSimClockGateSlcd0 = FSL_SIM_SCGC_BIT(3U, 30U), -#endif - - kSimClockGateEwm0 = FSL_SIM_SCGC_BIT(4U, 1U), - kSimClockGateCmt0 = FSL_SIM_SCGC_BIT(4U, 2U), - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUart3 = FSL_SIM_SCGC_BIT(4U, 13U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), -#endif - kSimClockGateCmp = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateLlwu0 = FSL_SIM_SCGC_BIT(4U, 28U), - - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGateTsi0 = FSL_SIM_SCGC_BIT(5U, 5U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - kSimClockGateFlexcan0 = FSL_SIM_SCGC_BIT(6U, 4U), -#endif - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(6U, 12U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(6U, 13U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbdcd0 = FSL_SIM_SCGC_BIT(6U, 21U), -#endif - kSimClockGatePdb0 = FSL_SIM_SCGC_BIT(6U, 22U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateFtm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateFtm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - - kSimClockGateFlexbus0 = FSL_SIM_SCGC_BIT(7U, 0U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 1U), - kSimClockGateMpu0 = FSL_SIM_SCGC_BIT(7U, 2U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_k20d10_t; -#else -} sim_clock_gate_name_t; -#endif - -/*! @} */ -/******************************************************************************* - * API - ******************************************************************************/ - - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetSdhcSrc(SIM_Type * base, - uint32_t instance, - clock_sdhc_src_t setting) -{ - SIM_BWR_SOPT2_SDHCSRC(base, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_HAL_GetSdhcSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_sdhc_src_t)SIM_BRD_SOPT2_SDHCSRC(base); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTimeSrc(SIM_Type * base, - uint32_t instance, - clock_time_src_t setting) -{ - SIM_BWR_SOPT2_TIMESRC(base, setting); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_time_src_t CLOCK_HAL_GetTimeSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_time_src_t)SIM_BRD_SOPT2_TIMESRC(base); -} - -/*! - * @brief Set the Ethernet RMII interface clock source selection. - * - * This function sets the Ethernet RMII interface clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRmiiSrc(SIM_Type * base, - uint32_t instance, - clock_rmii_src_t setting) -{ - SIM_BWR_SOPT2_RMIISRC(base, setting); -} - -/*! - * @brief Get the Ethernet RMII interface clock source selection. - * - * This function gets the Ethernet RMII interface clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_rmii_src_t CLOCK_HAL_GetRmiiSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_rmii_src_t)SIM_BRD_SOPT2_RMIISRC(base); -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} -#endif - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set debug trace clock selection. - * - * This function sets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTraceClkSrc(SIM_Type * base, clock_trace_src_t setting) -{ - SIM_BWR_SOPT2_TRACECLKSEL(base, setting); -} - -/*! - * @brief Get debug trace clock selection. - * - * This function gets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_trace_src_t CLOCK_HAL_GetTraceClkSrc(SIM_Type * base) -{ - return (clock_trace_src_t)SIM_BRD_SOPT2_TRACECLKSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV2. - * - * This function sets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv2(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV2(base, setting); -} - -/*! - * @brief Get OUTDIV2. - * - * This function gets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv2(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV2(base); -} - -/*! - * @brief Set OUTDIV3. - * - * This function sets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv3(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV3(base, setting); -} - -/*! - * @brief Get OUTDIV3. - * - * This function gets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv3(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV3(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac); - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac); -#endif - -/*! - * @brief Gets RAM size. - * - * This function gets the RAM size. The field specifies the amount of system RAM - * available on the device. - * - * @param base Base address for current SIM instance. - * @return size RAM size on the device - */ -static inline uint32_t SIM_HAL_GetRamSize(SIM_Type * base) -{ - return SIM_BRD_SOPT1_RAMSIZE(base); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif - -/*! - * @brief Sets the PTD7 pad drive strength setting. - * - * This function controls the output drive strength of the PTD7 pin by selecting - * either one or two pads to drive it. - * - * @param base Base address for current SIM instance. - * @param setting PTD7 pad drive strength setting - * - 0: Single-pad drive strength for PTD7. - * - 1: Double pad drive strength for PTD7. - */ -static inline void SIM_HAL_SetPtd7PadDriveStrengthMode(SIM_Type * base, - sim_ptd7pad_strengh_t setting) -{ - SIM_BWR_SOPT2_PTD7PAD(base, setting); -} - -/*! - * @brief Gets the PTD7 pad drive strength setting. - * - * This function gets the PTD7 pad drive strength setting. - * - * @param base Base address for current SIM instance. - * @return setting PTD7 pad drive strength setting - */ -static inline sim_ptd7pad_strengh_t SIM_HAL_GetPtd7PadDriveStrengthMode(SIM_Type * base) -{ - return (sim_ptd7pad_strengh_t)SIM_BRD_SOPT2_PTD7PAD(base); -} - -/*! - * @brief Sets the FlexBus security level setting. - * - * This function sets the FlexBus security level setting. If the security is enabled, - * this field affects which CPU operations can access the off-chip via the FlexBus - * and DDR controller interfaces. This field has no effect if the security is not enabled. - * - * @param base Base address for current SIM instance. - * @param setting FlexBus security level setting - * - 00: All off-chip accesses (op code and data) via the FlexBus and - * DDR controller are disallowed. - * - 10: Off-chip op code accesses are disallowed. Data accesses are - * allowed. - * - 11: Off-chip op code accesses and data accesses are allowed. - */ -static inline void SIM_HAL_SetFlexbusSecurityLevelMode(SIM_Type * base, - sim_flexbus_security_level_t setting) -{ - SIM_BWR_SOPT2_FBSL(base, setting); -} - -/*! - * @brief Gets the FlexBus security level setting. - * - * This function gets the FlexBus security level setting. - * - * @param base Base address for current SIM instance. - * @return setting FlexBus security level setting - */ -static inline sim_flexbus_security_level_t SIM_HAL_GetFlexbusSecurityLevelMode(SIM_Type * base) -{ - return (sim_flexbus_security_level_t)SIM_BRD_SOPT2_FBSL(base); -} - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select); - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select); - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the FlexTimer x hardware trigger y source select setting. - * - * This function selects the source of FTMx hardware trigger y. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @param select FlexTimer x hardware trigger y - * - 0: Pre-trigger A selected for ADCx. - * - 1: Pre-trigger B selected for ADCx. - */ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select); - -/*! - * @brief Gets the FlexTimer x hardware trigger y source select setting. - * - * This function gets the FlexTimer x hardware trigger y source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @return select FlexTimer x hardware trigger y source select setting - */ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger); - -/*! - * @brief Sets the FlexTimer x external clock pin select setting. - * - * This function selects the source of FTMx external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select FTMx external clock pin select - * - 0: FTMx external clock driven by FTM CLKIN0 pin. - * - 1: FTMx external clock driven by FTM CLKIN1 pin. - */ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select); - -/*! - * @brief Gets the FlexTimer x external clock pin select setting. - * - * This function gets the FlexTimer x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select FlexTimer x external clock pin select setting - */ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the FlexTimer x channel y input capture source select setting. - * - * This function selects the FlexTimer x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y input capture source - */ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y input capture source select setting. - * - * This function gets the FlexTimer x channel y input capture - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y input capture source select setting - */ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Sets the FlexTimer x fault y select setting. - * - * This function sets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @param select FlexTimer x fault y select setting - * - 0: FlexTimer x fault y select 0. - * - 1: FlexTimer x fault y select 1. - */ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select); - -/*! - * @brief Gets the FlexTimer x fault y select setting. - * - * This function gets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @return select FlexTimer x fault y select setting - */ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault); - -/*! - * @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Fam ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Fam ID - */ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the FlexNVM size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size FlexNVM Size - */ -static inline uint32_t SIM_HAL_GetFlexnvmSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_NVMSIZE(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Gets the EEProm size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the EEProm size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size EEProm Size - */ -static inline uint32_t SIM_HAL_GetEepromSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_EESIZE(base); -} - -/*! - * @brief Gets the FlexNVM partition in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM partition in the Flash Configuration Register1 - * - * @param base Base address for current SIM instance. - * @return setting FlexNVM partition setting - */ -static inline uint32_t SIM_HAL_GetFlexnvmPartition(SIM_Type * base) -{ - return SIM_BRD_FCFG1_DEPART(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -/*! - * @brief Gets the program flash in the Flash Configuration Register 2. - * - * This function gets the program flash maximum block 0 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return status program flash status - */ -static inline uint32_t SIM_HAL_GetProgramFlashCmd(SIM_Type * base) -{ - return SIM_BRD_FCFG2_PFLSH(base); -} - -/*! - * @brief Gets the Swap program flash flag in the Flash Configuration Register 2. - * - * This function gets the Swap program flash flag in the Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return status - Swap program flash flag(Active or Inactive) - */ -static inline bool SIM_HAL_GetSwapProgramFlash(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG2_SWAPPFLSH(base); -} - - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ -/*! @}*/ - - -#endif /* __FSL_SIM_HAL_K20D10_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK21DA5/fsl_sim_hal_MK21DA5.c b/KSDK_1.2.0/platform/hal/src/sim/MK21DA5/fsl_sim_hal_MK21DA5.c deleted file mode 100755 index 5e3a685..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK21DA5/fsl_sim_hal_MK21DA5.c +++ /dev/null @@ -1,715 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfDiv - * Description : Gets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - SIM_BWR_SOPT4_FTM0FLT0(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0FLT1(base, select); - break; - default: - break; - } - break; - case 1: - SIM_BWR_SOPT4_FTM1FLT0(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2FLT0(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault) -{ - sim_ftm_flt_sel_t retValue = (sim_ftm_flt_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT0(base); - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT1(base); - break; - default: - break; - } - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM1FLT0(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM2FLT0(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK21DA5/fsl_sim_hal_MK21DA5.h b/KSDK_1.2.0/platform/hal/src/sim/MK21DA5/fsl_sim_hal_MK21DA5.h deleted file mode 100644 index d49b8d9..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK21DA5/fsl_sim_hal_MK21DA5.h +++ /dev/null @@ -1,1435 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_K21DA5_H__) -#define __FSL_SIM_HAL_K21DA5_H__ - -/*! @addtogroup sim_hal_k21da5*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief WDOG clock source select */ -typedef enum _clock_wdog_src_t -{ - kClockWdogSrcLpoClk, /* LPO */ - kClockWdogSrcAltClk, /* Alternative clock, for K21DA5 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_wdog_src_k21da5_t; -#else -} clock_wdog_src_t; -#endif - -/*! @brief Debug trace clock source select */ -typedef enum _clock_trace_src_t -{ - kClockTraceSrcMcgoutClk, /*!< MCG out clock */ - kClockTraceSrcCoreClk /*!< core clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_trace_src_k21da5_t; -#else -} clock_trace_src_t; -#endif - -/*! @brief PORTx digital input filter clock source select */ -typedef enum _clock_port_filter_src_t -{ - kClockPortFilterSrcBusClk, /*!< Bus clock */ - kClockPortFilterSrcLpoClk /*!< LPO */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_port_filter_src_k21da5_t; -#else -} clock_port_filter_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG IRC clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_k21da5_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief SIM timestamp clock source */ -typedef enum _clock_time_src -{ - kClockTimeSrcCoreSysClk, /*!< Core/system clock */ - kClockTimeSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTimeSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTimeSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_time_src_k21da5_t; -#else -} clock_time_src_t; -#endif - -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcPllFllSel, /*!< Clock divider USB FS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_k21da5_t; -#else -} clock_usbfs_src_t; -#endif - - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_k21da5_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll = 0U, /*!< Fll clock */ - kClockPllFllSelPll = 1U, /*!< Pll0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_k21da5_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_k21da5_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCG out clock */ - kClockClkoutSelRtc32kClk = 5U, /*!< RTC 32k clock */ - kClockClkoutSelOsc0erClk = 6U /*!< OSCERCLK0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_k21da5_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz /*!< 32kHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_k21da5_t; -#else -} clock_rtcout_src_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_k21da5_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_k21da5_t; -#else -} sim_usbvstby_mode_t; -#endif - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_k21da5_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /*!< High speed comparator 0 output */ - kSimAdcTrgSelHighSpeedComp1 = 2U, /*!< High speed comparator 1 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelPit2 = 6U, /*!< PIT trigger 2 */ - kSimAdcTrgSelPit3 = 7U, /*!< PIT trigger 3 */ - kSimAdcTrgSelFtm0 = 8U, /*!< FTM0 trigger */ - kSimAdcTrgSelFtm1 = 9U, /*!< FTM1 trigger */ - kSimAdcTrgSelFtm2 = 10U, /*!< FTM2 trigger */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_k21da5_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ - kSimUartRxsrcCmp1, /*!< CMP1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_k21da5_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcFtm1, /*!< UARTx_TX pin modulated with FTM1 channel 0 output */ - kSimUartTxsrcFtm2 /*!< UARTx_TX pin modulated with FTM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_k21da5_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM FlexTimer x trigger y select */ -typedef enum _sim_ftm_trg_src -{ - kSimFtmTrgSrc0, /*!< FlexTimer x trigger y select 0 */ - kSimFtmTrgSrc1 /*!< FlexTimer x trigger y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_trg_src_k21da5_t; -#else -} sim_ftm_trg_src_t; -#endif - -/*! @brief SIM FlexTimer external clock select */ -typedef enum _sim_ftm_clk_sel -{ - kSimFtmClkSel0, /*!< FTM CLKIN0 pin. */ - kSimFtmClkSel1 /*!< FTM CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_clk_sel_k21da5_t; -#else -} sim_ftm_clk_sel_t; -#endif - -/*! @brief SIM FlexTimer x channel y input capture source select */ -typedef enum _sim_ftm_ch_src -{ - kSimFtmChSrc0, /*!< FlexTimer x channel y input capture source 0. */ - kSimFtmChSrc1, /*!< FlexTimer x channel y input capture source 1. */ - kSimFtmChSrc2, /*!< FlexTimer x channel y input capture source 2. */ - kSimFtmChSrc3 /*!< FlexTimer x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_ch_src_k21da5_t; -#else -} sim_ftm_ch_src_t; -#endif - -/*! @brief SIM FlexTimer x Fault y select */ -typedef enum _sim_ftm_flt_sel -{ - kSimFtmFltSel0, /*!< FlexTimer x fault y select 0 */ - kSimFtmFltSel1 /*!< FlexTimer x fault y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_flt_sel_k21da5_t; -#else -} sim_ftm_flt_sel_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_k21da5_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1 /*!< CMP0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_k21da5_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM CMT/UART pad drive strength */ -typedef enum _sim_cmtuartpad_strengh -{ - kSimCmtuartSinglePad, /*!< Single-pad drive strength for CMT IRO or UART0_TXD */ - kSimCmtuartDualPad /*!< Dual-pad drive strength for CMT IRO or UART0_TXD */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_cmtuartpad_strengh_k21da5_t; -#else -} sim_cmtuartpad_strengh_t; -#endif - -/*! @brief SIM PTD7 pad drive strength */ -typedef enum _sim_ptd7pad_strengh -{ - kSimPtd7padSinglePad, /*!< Single-pad drive strength for PTD7 */ - kSimPtd7padDualPad /*!< Dual-pad drive strength for PTD7 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ptd7pad_strengh_k21da5_t; -#else -} sim_ptd7pad_strengh_t; -#endif - - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateEwm0 = FSL_SIM_SCGC_BIT(4U, 1U), - kSimClockGateCmt0 = FSL_SIM_SCGC_BIT(4U, 2U), - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUart3 = FSL_SIM_SCGC_BIT(4U, 13U), - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), - kSimClockGateCmp = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateRnga0 = FSL_SIM_SCGC_BIT(6U, 9U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(6U, 12U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(6U, 13U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), - kSimClockGateUsbdcd0 = FSL_SIM_SCGC_BIT(6U, 21U), - kSimClockGatePdb0 = FSL_SIM_SCGC_BIT(6U, 22U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateFtm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateFtm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateFtm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(6U, 31U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 1U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_k21da5_t; -#else -} sim_clock_gate_name_t; -#endif - - -/*! @} */ -/******************************************************************************* - * API - ******************************************************************************/ - - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set debug trace clock selection. - * - * This function sets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTraceClkSrc(SIM_Type * base, clock_trace_src_t setting) -{ - SIM_BWR_SOPT2_TRACECLKSEL(base, setting); -} - -/*! - * @brief Get debug trace clock selection. - * - * This function gets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_trace_src_t CLOCK_HAL_GetTraceClkSrc(SIM_Type * base) -{ - return (clock_trace_src_t)SIM_BRD_SOPT2_TRACECLKSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV2. - * - * This function sets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv2(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV2(base, setting); -} - -/*! - * @brief Get OUTDIV2. - * - * This function gets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv2(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV2(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac); - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac); - -/*! - * @brief Gets RAM size. - * - * This function gets the RAM size. The field specifies the amount of system RAM - * available on the device. - * - * @param base Base address for current SIM instance. - * @return size RAM size on the device - */ -static inline uint32_t SIM_HAL_GetRamSize(SIM_Type * base) -{ - return SIM_BRD_SOPT1_RAMSIZE(base); -} - -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} - -/*! - * @brief Sets the PTD7 pad drive strength setting. - * - * This function controls the output drive strength of the PTD7 pin by selecting - * either one or two pads to drive it. - * - * @param base Base address for current SIM instance. - * @param setting PTD7 pad drive strength setting - * - 0: Single-pad drive strength for PTD7. - * - 1: Double pad drive strength for PTD7. - */ -static inline void SIM_HAL_SetPtd7PadDriveStrengthMode(SIM_Type * base, - sim_ptd7pad_strengh_t setting) -{ - SIM_BWR_SOPT2_PTD7PAD(base, setting); -} - -/*! - * @brief Gets the PTD7 pad drive strength setting. - * - * This function gets the PTD7 pad drive strength setting. - * - * @param base Base address for current SIM instance. - * @return setting PTD7 pad drive strength setting - */ -static inline sim_ptd7pad_strengh_t SIM_HAL_GetPtd7PadDriveStrengthMode(SIM_Type * base) -{ - return (sim_ptd7pad_strengh_t)SIM_BRD_SOPT2_PTD7PAD(base); -} - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select); - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select); - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the FlexTimer x hardware trigger y source select setting. - * - * This function selects the source of FTMx hardware trigger y. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @param select FlexTimer x hardware trigger y - * - 0: Pre-trigger A selected for ADCx. - * - 1: Pre-trigger B selected for ADCx. - */ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select); - -/*! - * @brief Gets the FlexTimer x hardware trigger y source select setting. - * - * This function gets the FlexTimer x hardware trigger y source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @return select FlexTimer x hardware trigger y source select setting - */ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger); - -/*! - * @brief Sets the FlexTimer x external clock pin select setting. - * - * This function selects the source of FTMx external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select FTMx external clock pin select - * - 0: FTMx external clock driven by FTM CLKIN0 pin. - * - 1: FTMx external clock driven by FTM CLKIN1 pin. - */ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select); - -/*! - * @brief Gets the FlexTimer x external clock pin select setting. - * - * This function gets the FlexTimer x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select FlexTimer x external clock pin select setting - */ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the FlexTimer x channel y input capture source select setting. - * - * This function selects the FlexTimer x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y input capture source - */ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y input capture source select setting. - * - * This function gets the FlexTimer x channel y input capture - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y input capture source select setting - */ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Sets the FlexTimer x fault y select setting. - * - * This function sets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @param select FlexTimer x fault y select setting - * - 0: FlexTimer x fault y select 0. - * - 1: FlexTimer x fault y select 1. - */ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select); - -/*! - * @brief Gets the FlexTimer x fault y select setting. - * - * This function gets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @return select FlexTimer x fault y select setting - */ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault); - -/*! - * @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Fam ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Fam ID - */ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the FlexNVM size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size FlexNVM Size - */ -static inline uint32_t SIM_HAL_GetFlexnvmSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_NVMSIZE(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Gets the EEProm size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the EEProm size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size EEProm Size - */ -static inline uint32_t SIM_HAL_GetEepromSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_EESIZE(base); -} - -/*! - * @brief Gets the FlexNVM partition in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM partition in the Flash Configuration Register1 - * - * @param base Base address for current SIM instance. - * @return setting FlexNVM partition setting - */ -static inline uint32_t SIM_HAL_GetFlexnvmPartition(SIM_Type * base) -{ - return SIM_BRD_FCFG1_DEPART(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -/*! - * @brief Gets the program flash in the Flash Configuration Register 2. - * - * This function gets the program flash maximum block 0 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return status program flash status - */ -static inline uint32_t SIM_HAL_GetProgramFlashCmd(SIM_Type * base) -{ - return SIM_BRD_FCFG2_PFLSH(base); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ -/*! @}*/ - - -#endif /* __FSL_SIM_HAL_k21da5_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK21FA12/fsl_sim_hal_MK21FA12.c b/KSDK_1.2.0/platform/hal/src/sim/MK21FA12/fsl_sim_hal_MK21FA12.c deleted file mode 100755 index e78a1ef..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK21FA12/fsl_sim_hal_MK21FA12.c +++ /dev/null @@ -1,786 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB devider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfDiv - * Description : Gets USB devider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV3(outdiv3); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = SIM_BRD_CLKDIV1_OUTDIV3(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - case 3: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM3TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM3TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - case 3: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM3TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM3TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - case 3: - SIM_BWR_SOPT4_FTM3CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - case 3: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM3CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - SIM_BWR_SOPT4_FTM0FLT0(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0FLT1(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM0FLT2(base, select); - break; - default: - break; - } - break; - case 1: - SIM_BWR_SOPT4_FTM1FLT0(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2FLT0(base, select); - break; - case 3: - SIM_BWR_SOPT4_FTM3FLT0(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault) -{ - sim_ftm_flt_sel_t retValue = (sim_ftm_flt_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT0(base); - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT1(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT2(base); - break; - default: - break; - } - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM1FLT0(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM2FLT0(base); - break; - case 3: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM3FLT0(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK21FA12/fsl_sim_hal_MK21FA12.h b/KSDK_1.2.0/platform/hal/src/sim/MK21FA12/fsl_sim_hal_MK21FA12.h deleted file mode 100644 index 454efb6..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK21FA12/fsl_sim_hal_MK21FA12.h +++ /dev/null @@ -1,1578 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_MK21FA12_H__) -#define __FSL_SIM_HAL_MK21FA12_H__ - -/*! - * @addtogroup sim_hal_k21fa12 - * @{ - */ -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief WDOG clock source select */ -typedef enum _clock_wdog_src_t -{ - kClockWdogSrcLpoClk, /*!< LPO */ - kClockWdogSrcAltClk, /*!< Alternative clock, for MK21FA12 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_wdog_src_k21fa12_t; -#else -} clock_wdog_src_t; -#endif - -/*! @brief Debug trace clock source select */ -typedef enum _clock_trace_src_t -{ - kClockTraceSrcMcgoutClk, /*!< MCG out clock */ - kClockTraceSrcCoreClk, /*!< core clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_trace_src_k21fa12_t; -#else -} clock_trace_src_t; -#endif - -/*! @brief PORTx digital input filter clock source select */ -typedef enum _clock_port_filter_src_t -{ - kClockPortFilterSrcBusClk, /*!< Bus clock */ - kClockPortFilterSrcLpoClk, /*!< LPO */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_port_filter_src_k21fa12_t; -#else -} clock_port_filter_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCGIRCLK */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk, /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_k21fa12_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcPllFllSel, /*!< Clock divider USB FS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_k21fa12_t; -#else -} clock_usbfs_src_t; -#endif - -/*! @brief FLEXCAN clock source select */ -typedef enum _clock_flexcan_src_t -{ - kClockFlexcanSrcOsc0erClk, /*!< OSCERCLK */ - kClockFlexcanSrcBusClk /*!< Bus clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_flexcan_src_k21fa12_t; -#else -} clock_flexcan_src_t; -#endif - -/*! @brief SDHC clock source */ -typedef enum _clock_sdhc_src -{ - kClockSdhcSrcCoreSysClk, /*!< Core/system clock */ - kClockSdhcSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockSdhcSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockSdhcSrcExt /*!< External bypass clock (SDHC0_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sdhc_src_k21fa12_t; -#else -} clock_sdhc_src_t; -#endif - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_k21fa12_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll = 0U, /*!< Fll clock */ - kClockPllFllSelPll = 1U, /*!< Pll0 clock */ - kClockPllFllSelIrc48M = 3U /*!< IRC48MCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_k21fa12_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U, /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_k21fa12_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlexbusClk = 0U, /*!< Flexbus clock */ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCGIRCLK */ - kClockClkoutSelRtc = 5U, /*!< RTC 32k clock */ - kClockClkoutSelOsc0erClk = 6U, /*!< OSC0ERCLK */ - kClockClkoutSelIrc48M = 7U, /*!< IRC48MCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_k21fa12_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz, /*!< 32kHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_k21fa12_t; -#else -} clock_rtcout_src_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_k21fa12_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_k21fa12_t; -#else -} sim_usbvstby_mode_t; -#endif - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_k21fa12_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /*!< High speed comparator 0 output */ - kSimAdcTrgSelHighSpeedComp1 = 2U, /*!< High speed comparator 1 output */ - kSimAdcTrgSelHighSpeedComp2 = 3U, /*!< High speed comparator 2 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelPit2 = 6U, /*!< PIT trigger 2 */ - kSimAdcTrgSelPit3 = 7U, /*!< PIT trigger 3 */ - kSimAdcTrgSelFtm0 = 8U, /*!< FTM0 trigger */ - kSimAdcTrgSelFtm1 = 9U, /*!< FTM1 trigger */ - kSimAdcTrgSelFtm2 = 10U, /*!< FTM2 trigger */ - kSimAdcTrgSelFtm3 = 11U, /*!< FTM3 trigger */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U, /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_k21fa12_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ - kSimUartRxsrcCmp1, /*!< CMP1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_k21fa12_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcFtm1, /*!< UARTx_TX pin modulated with FTM1 channel 0 output */ - kSimUartTxsrcFtm2, /*!< UARTx_TX pin modulated with FTM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_k21fa12_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM FlexTimer x trigger y select */ -typedef enum _sim_ftm_trg_src -{ - kSimFtmTrgSrc0, /*!< FlexTimer x trigger y select 0 */ - kSimFtmTrgSrc1 /*!< FlexTimer x trigger y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_trg_src_k21fa12_t; -#else -} sim_ftm_trg_src_t; -#endif - -/*! @brief SIM FlexTimer external clock select */ -typedef enum _sim_ftm_clk_sel -{ - kSimFtmClkSel0, /*!< FTM CLKIN0 pin. */ - kSimFtmClkSel1 /*!< FTM CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_clk_sel_k21fa12_t; -#else -} sim_ftm_clk_sel_t; -#endif - -/*! @brief SIM FlexTimer x channel y input capture source select */ -typedef enum _sim_ftm_ch_src -{ - kSimFtmChSrc0, /*!< FlexTimer x channel y input capture source 0. */ - kSimFtmChSrc1, /*!< FlexTimer x channel y input capture source 1. */ - kSimFtmChSrc2, /*!< FlexTimer x channel y input capture source 2. */ - kSimFtmChSrc3, /*!< FlexTimer x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_ch_src_k21fa12_t; -#else -} sim_ftm_ch_src_t; -#endif - -/*! @brief SIM FlexTimer x Fault y select */ -typedef enum _sim_ftm_flt_sel -{ - kSimFtmFltSel0, /*!< FlexTimer x fault y select 0 */ - kSimFtmFltSel1 /*!< FlexTimer x fault y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_flt_sel_k21fa12_t; -#else -} sim_ftm_flt_sel_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_k21fa12_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPM x channel y input capture source 0. */ - kSimTpmChSrc1, /*!< TPM x channel y input capture source 1. */ - kSimTpmChSrc2, /*!< TPM x channel y input capture source 2. */ - kSimTpmChSrc3, /*!< TPM x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_k21fa12_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM CMT/UART pad drive strength */ -typedef enum _sim_cmtuartpad_strengh -{ - kSimCmtuartSinglePad, /*!< Single-pad drive strength for CMT IRO or UART0_TXD */ - kSimCmtuartDualPad /*!< Dual-pad drive strength for CMT IRO or UART0_TXD */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_cmtuartpad_strengh_k21fa12_t; -#else -} sim_cmtuartpad_strengh_t; -#endif - -/*! @brief SIM PTD7 pad drive strength */ -typedef enum _sim_ptd7pad_strengh -{ - kSimPtd7padSinglePad, /*!< Single-pad drive strength for PTD7 */ - kSimPtd7padDualPad /*!< Dual-pad drive strength for PTD7 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ptd7pad_strengh_k21fa12_t; -#else -} sim_ptd7pad_strengh_t; -#endif - -/*! @brief SIM FlexBus security level */ -typedef enum _sim_flexbus_security_level -{ - kSimFbslLevel0, /*!< FlexBus security level 0. */ - kSimFbslLevel1, /*!< FlexBus security level 1. */ - kSimFbslLevel2, /*!< FlexBus security level 2. */ - kSimFbslLevel3, /*!< FlexBus security level 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_flexbus_security_level_k21fa12_t; -#else -} sim_flexbus_security_level_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateI2c2 = FSL_SIM_SCGC_BIT(1U, 6U), - kSimClockGateUart4 = FSL_SIM_SCGC_BIT(1U, 10U), - kSimClockGateUart5 = FSL_SIM_SCGC_BIT(1U, 11U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(2U, 12U), - kSimClockGateDac1 = FSL_SIM_SCGC_BIT(2U, 13U), - kSimClockGateSpi2 = FSL_SIM_SCGC_BIT(3U, 12U), - kSimClockGateSdhc0 = FSL_SIM_SCGC_BIT(3U, 17U), - kSimClockGateFtm3 = FSL_SIM_SCGC_BIT(3U, 25U), - kSimClockGateAdc1 = FSL_SIM_SCGC_BIT(3U, 27U), - kSimClockGateEwm0 = FSL_SIM_SCGC_BIT(4U, 1U), - kSimClockGateCmt0 = FSL_SIM_SCGC_BIT(4U, 2U), - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUart3 = FSL_SIM_SCGC_BIT(4U, 13U), - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), - kSimClockGateCmp = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateFlexcan0 = FSL_SIM_SCGC_BIT(6U, 4U), - kSimClockGateRnga0 = FSL_SIM_SCGC_BIT(6U, 9U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(6U, 12U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(6U, 13U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), - kSimClockGateUsbdcd0 = FSL_SIM_SCGC_BIT(6U, 21U), - kSimClockGatePdb0 = FSL_SIM_SCGC_BIT(6U, 22U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateFtm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateFtm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateFtm2 = FSL_SIM_SCGC_BIT(3U, 24U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateFlexbus0 = FSL_SIM_SCGC_BIT(7U, 0U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 1U), - kSimClockGateMpu0 = FSL_SIM_SCGC_BIT(7U, 2U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_k21fa12_t; -#else -} sim_clock_gate_name_t; -#endif - -/*@}*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function gets the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetSdhcSrc(SIM_Type * base, - uint32_t instance, - clock_sdhc_src_t setting) -{ - SIM_BWR_SOPT2_SDHCSRC(base, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_HAL_GetSdhcSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_sdhc_src_t)SIM_BRD_SOPT2_SDHCSRC(base); -} - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac); - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac); - - -/*! - * @brief Set debug trace clock selection. - * - * This function sets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTraceClkSrc(SIM_Type * base, clock_trace_src_t setting) -{ - SIM_BWR_SOPT2_TRACECLKSEL(base, setting); -} - -/*! - * @brief Get debug trace clock selection. - * - * This function gets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_trace_src_t CLOCK_HAL_GetTraceClkSrc(SIM_Type * base) -{ - return (clock_trace_src_t)SIM_BRD_SOPT2_TRACECLKSEL(base); -} - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV2. - * - * This function sets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv2(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV2(base, setting); -} - -/*! - * @brief Get OUTDIV2. - * - * This function gets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv2(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV2(base); -} - -/*! - * @brief Set OUTDIV3. - * - * This function sets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv3(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV3(base, setting); -} - -/*! - * @brief Get OUTDIV3. - * - * This function gets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv3(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV3(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); -/*! - * @brief Gets RAM size. - * - * This function gets the RAM size. The field specifies the amount of system RAM - * available on the device. - * - * @param base Base address for current SIM instance. - * @return size RAM size on the device - */ -static inline uint32_t SIM_HAL_GetRamSize(SIM_Type * base) -{ - return SIM_BRD_SOPT1_RAMSIZE(base); -} - -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} - -/*! - * @brief Sets the PTD7 pad drive strength setting. - * - * This function controls the output drive strength of the PTD7 pin by selecting - * either one or two pads to drive it. - * - * @param base Base address for current SIM instance. - * @param setting PTD7 pad drive strength setting - * - 0: Single-pad drive strength for PTD7. - * - 1: Double pad drive strength for PTD7. - */ -static inline void SIM_HAL_SetPtd7PadDriveStrengthMode(SIM_Type * base, - sim_ptd7pad_strengh_t setting) -{ - SIM_BWR_SOPT2_PTD7PAD(base, setting); -} - -/*! - * @brief Gets the PTD7 pad drive strength setting. - * - * This function gets the PTD7 pad drive strength setting. - * - * @param base Base address for current SIM instance. - * @return setting PTD7 pad drive strength setting - */ -static inline sim_ptd7pad_strengh_t SIM_HAL_GetPtd7PadDriveStrengthMode(SIM_Type * base) -{ - return (sim_ptd7pad_strengh_t)SIM_BRD_SOPT2_PTD7PAD(base); -} - -/*! - * @brief Sets the FlexBus security level setting. - * - * This function sets the FlexBus security level setting. If the security is enabled, - * this field affects which CPU operations can access the off-chip via the FlexBus - * and DDR controller interfaces. This field has no effect if the security is not enabled. - * - * @param base Base address for current SIM instance. - * @param setting FlexBus security level setting - * - 00: All off-chip accesses (op code and data) via the FlexBus and - * DDR controller are disallowed. - * - 10: Off-chip op code accesses are disallowed. Data accesses are - * allowed. - * - 11: Off-chip op code accesses and data accesses are allowed. - */ -static inline void SIM_HAL_SetFlexbusSecurityLevelMode(SIM_Type * base, - sim_flexbus_security_level_t setting) -{ - SIM_BWR_SOPT2_FBSL(base, setting); -} - -/*! - * @brief Gets the FlexBus security level setting. - * - * This function gets the FlexBus security level setting. - * - * @param base Base address for current SIM instance. - * @return setting FlexBus security level setting - */ -static inline sim_flexbus_security_level_t SIM_HAL_GetFlexbusSecurityLevelMode(SIM_Type * base) -{ - return (sim_flexbus_security_level_t)SIM_BRD_SOPT2_FBSL(base); -} - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select); - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select); - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the FlexTimer x hardware trigger y source select setting. - * - * This function selects the source of FTMx hardware trigger y. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @param select FlexTimer x hardware trigger y - * - 0: Pre-trigger A selected for ADCx. - * - 1: Pre-trigger B selected for ADCx. - */ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select); - -/*! - * @brief Gets the FlexTimer x hardware trigger y source select setting. - * - * This function gets the FlexTimer x hardware trigger y source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @return select FlexTimer x hardware trigger y source select setting - */ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger); - -/*! - * @brief Sets the FlexTimer x external clock pin select setting. - * - * This function selects the source of FTMx external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select FTMx external clock pin select - * - 0: FTMx external clock driven by FTM CLKIN0 pin. - * - 1: FTMx external clock driven by FTM CLKIN1 pin. - */ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select); - -/*! - * @brief Gets the FlexTimer x external clock pin select setting. - * - * This function gets the FlexTimer x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select FlexTimer x external clock pin select setting - */ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the FlexTimer x channel y input capture source select setting. - * - * This function selects the FlexTimer x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y input capture source - */ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y input capture source select setting. - * - * This function gets the FlexTimer x channel y input capture - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y input capture source select setting - */ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Sets the FlexTimer x fault y select setting. - * - * This function sets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @param select FlexTimer x fault y select setting - * - 0: FlexTimer x fault y select 0. - * - 1: FlexTimer x fault y select 1. - */ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select); - -/*! - * @brief Gets the FlexTimer x fault y select setting. - * - * This function gets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @return select FlexTimer x fault y select setting - */ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault); - -/*! - * @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Fam ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Fam ID - */ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the Kinetis Die ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Die ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Die ID - */ -static inline uint32_t SIM_HAL_GetDieId(SIM_Type * base) -{ - return SIM_BRD_SDID_DIEID(base); -} - -/*! - * @brief Gets the FlexNVM size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size FlexNVM Size - */ -static inline uint32_t SIM_HAL_GetFlexnvmSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_NVMSIZE(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Gets the EEProm size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the EEProm size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size EEProm Size - */ -static inline uint32_t SIM_HAL_GetEepromSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_EESIZE(base); -} - -/*! - * @brief Gets the FlexNVM partition in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM partition in the Flash Configuration Register1 - * - * @param base Base address for current SIM instance. - * @return setting FlexNVM partition setting - */ -static inline uint32_t SIM_HAL_GetFlexnvmPartition(SIM_Type * base) -{ - return SIM_BRD_FCFG1_DEPART(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -/*! - * @brief Gets the program flash in the Flash Configuration Register 2. - * - * This function gets the program flash maximum block 0 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return status program flash status - */ -static inline uint32_t SIM_HAL_GetProgramFlashCmd(SIM_Type * base) -{ - return SIM_BRD_FCFG2_PFLSH(base); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_SIM_HAL_MK21FA12_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK22F12810/fsl_sim_hal_MK22F12810.c b/KSDK_1.2.0/platform/hal/src/sim/MK22F12810/fsl_sim_hal_MK22F12810.c deleted file mode 100755 index d0c40b2..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK22F12810/fsl_sim_hal_MK22F12810.c +++ /dev/null @@ -1,813 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfDiv - * Description : Gets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM2CH1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - case 1: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/* Macro for FTMxOCHySRC. */ -#define FTM_CH_OUT_SRC_MASK(instance, channel) (1U << (channel + 16U)) - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChOutSrcMode - * Description : FlexTimer x channel y output source select setting. - * This function will select FlexTimer x channel y output source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_out_src_t select) -{ - assert (0U==instance); - assert (8U>channel); - - if (kSimFtmChOutSrc0 == select) - { - SIM_CLR_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } - else - { - SIM_SET_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChOutSrcMode - * Description : Get FlexTimer x channel y output source select setting - * This function will get FlexTimer x channel y output source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_out_src_t SIM_HAL_GetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - assert (0U==instance); - assert (8U>channel); - return (sim_ftm_ch_out_src_t) - (SIM_RD_SOPT8(base) & FTM_CH_OUT_SRC_MASK(instance, channel)); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmSyncCmd - * Description : Set FTMxSYNCBIT - * This function sets FlexTimer x hardware trigger 0 software synchronization. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmSyncCmd(SIM_Type * base, uint32_t instance, bool sync) -{ - assert (instance < FTM_INSTANCE_COUNT); - if (sync) - { - SIM_SET_SOPT8(base, (1U< -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfDiv - * Description : Gets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM2CH1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - case 1: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/* Macro for FTMxOCHySRC. */ -#define FTM_CH_OUT_SRC_MASK(instance, channel) (1U << (channel + 16U)) - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChOutSrcMode - * Description : FlexTimer x channel y output source select setting. - * This function will select FlexTimer x channel y output source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_out_src_t select) -{ - assert (0U==instance); - assert (8U>channel); - - if (kSimFtmChOutSrc0 == select) - { - SIM_CLR_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } - else - { - SIM_SET_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChOutSrcMode - * Description : Get FlexTimer x channel y output source select setting - * This function will get FlexTimer x channel y output source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_out_src_t SIM_HAL_GetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - assert (0U==instance); - assert (8U>channel); - return (sim_ftm_ch_out_src_t) - (SIM_RD_SOPT8(base) & FTM_CH_OUT_SRC_MASK(instance, channel)); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmSyncCmd - * Description : Set FTMxSYNCBIT - * This function sets FlexTimer x hardware trigger 0 software synchronization. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmSyncCmd(SIM_Type * base, uint32_t instance, bool sync) -{ - assert (instance < FTM_INSTANCE_COUNT); - if (sync) - { - SIM_SET_SOPT8(base, (1U< -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfDiv - * Description : Gets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV3(outdiv3); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = SIM_BRD_CLKDIV1_OUTDIV3(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - case 3: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM3TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM3TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - case 3: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM3TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM3TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - case 3: - SIM_BWR_SOPT4_FTM3CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - case 3: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM3CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM2CH1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - case 1: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/* Macro for FTMxOCHySRC. */ -#define FTM_CH_OUT_SRC_MASK(instance, channel) \ - (1U << ((((instance)>>1U)*8U) + channel + 16U)) - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChOutSrcMode - * Description : FlexTimer x channel y output source select setting. - * This function will select FlexTimer x channel y output source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_out_src_t select) -{ - assert ((0U==instance) || (3U==instance)); - assert (8U>channel); - - if (kSimFtmChOutSrc0 == select) - { - SIM_CLR_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } - else - { - SIM_SET_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChOutSrcMode - * Description : Get FlexTimer x channel y output source select setting - * This function will get FlexTimer x channel y output source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_out_src_t SIM_HAL_GetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - assert ((0U==instance) || (3U==instance)); - assert (8U>channel); - return (sim_ftm_ch_out_src_t) - (SIM_RD_SOPT8(base) & FTM_CH_OUT_SRC_MASK(instance, channel)); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmSyncCmd - * Description : Set FTMxSYNCBIT - * This function sets FlexTimer x hardware trigger 0 software synchronization. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmSyncCmd(SIM_Type * base, uint32_t instance, bool sync) -{ - assert (instance < FTM_INSTANCE_COUNT); - if (sync) - { - SIM_SET_SOPT8(base, (1U< -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfDiv - * Description : Gets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV3(outdiv3); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = SIM_BRD_CLKDIV1_OUTDIV3(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - case 3: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM3TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM3TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - case 3: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM3TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM3TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - case 3: - SIM_BWR_SOPT4_FTM3CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - case 3: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM3CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - SIM_BWR_SOPT4_FTM0FLT0(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0FLT1(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM0FLT2(base, select); - break; - default: - break; - } - break; - case 1: - SIM_BWR_SOPT4_FTM1FLT0(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2FLT0(base, select); - break; - case 3: - SIM_BWR_SOPT4_FTM3FLT0(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault) -{ - sim_ftm_flt_sel_t retValue = (sim_ftm_flt_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT0(base); - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT1(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT2(base); - break; - default: - break; - } - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM1FLT0(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM2FLT0(base); - break; - case 3: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM3FLT0(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK24F12/fsl_sim_hal_MK24F12.h b/KSDK_1.2.0/platform/hal/src/sim/MK24F12/fsl_sim_hal_MK24F12.h deleted file mode 100644 index 66dceb8..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK24F12/fsl_sim_hal_MK24F12.h +++ /dev/null @@ -1,1627 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_K24F12_H__) -#define __FSL_SIM_HAL_K24F12_H__ - -/*! - * @addtogroup sim_hal_k24f12 - * @{ - */ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief WDOG clock source select */ -typedef enum _clock_wdog_src_t -{ - kClockWdogSrcLpoClk, /*!< LPO */ - kClockWdogSrcAltClk /*!< Alternative clock, for this SOC it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_wdog_src_k24f12_t; -#else -} clock_wdog_src_t; -#endif - -/*! @brief Debug trace clock source select */ -typedef enum _clock_trace_src_t -{ - kClockTraceSrcMcgoutClk, /*!< MCG out clock */ - kClockTraceSrcCoreClk /*!< core clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_trace_src_k24f12_t; -#else -} clock_trace_src_t; -#endif - -/*! @brief PORTx digital input filter clock source select */ -typedef enum _clock_port_filter_src_t -{ - kClockPortFilterSrcBusClk, /*!< Bus clock */ - kClockPortFilterSrcLpoClk /*!< LPO */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_port_filter_src_k24f12_t; -#else -} clock_port_filter_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCGIRCLK */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_k24f12_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcPllFllSel /*!< Clock divider USB FS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_k24f12_t; -#else -} clock_usbfs_src_t; -#endif - -/*! @brief FLEXCAN clock source select */ -typedef enum _clock_flexcan_src_t -{ - kClockFlexcanSrcOsc0erClk, /*!< OSCERCLK */ - kClockFlexcanSrcBusClk /*!< Bus clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_flexcan_src_k24f12_t; -#else -} clock_flexcan_src_t; -#endif - -/*! @brief SDHC clock source */ -typedef enum _clock_sdhc_src -{ - kClockSdhcSrcCoreSysClk, /*!< Core/system clock */ - kClockSdhcSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockSdhcSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockSdhcSrcExt /*!< External bypass clock (SDHC0_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sdhc_src_k24f12_t; -#else -} clock_sdhc_src_t; -#endif - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_k24f12_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll = 0U, /*!< Fll clock */ - kClockPllFllSelPll = 1U, /*!< Pll0 clock */ - kClockPllFllSelIrc48M = 3U /*!< IRC48MCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_k24f12_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_k24f12_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlexbusClk = 0U, /*!< Flexbus clock */ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCGIRCLK */ - kClockClkoutSelRtc = 5U, /*!< RTC 32k clock */ - kClockClkoutSelOsc0erClk = 6U, /*!< OSC0ERCLK */ - kClockClkoutSelIrc48M = 7U, /*!< IRC48MCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_k24f12_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz, /*!< 32kHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_k24f12_t; -#else -} clock_rtcout_src_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_k24f12_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_k24f12_t; -#else -} sim_usbvstby_mode_t; -#endif - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_k24f12_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /*!< High speed comparator 0 output */ - kSimAdcTrgSelHighSpeedComp1 = 2U, /*!< High speed comparator 1 output */ - kSimAdcTrgSelHighSpeedComp2 = 3U, /*!< High speed comparator 2 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelPit2 = 6U, /*!< PIT trigger 2 */ - kSimAdcTrgSelPit3 = 7U, /*!< PIT trigger 3 */ - kSimAdcTrgSelFtm0 = 8U, /*!< FTM0 trigger */ - kSimAdcTrgSelFtm1 = 9U, /*!< FTM1 trigger */ - kSimAdcTrgSelFtm2 = 10U, /*!< FTM2 trigger */ - kSimAdcTrgSelFtm3 = 11U, /*!< FTM3 trigger */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U, /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_k24f12_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ - kSimUartRxsrcCmp1, /*!< CMP1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_k24f12_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcFtm1, /*!< UARTx_TX pin modulated with FTM1 channel 0 output */ - kSimUartTxsrcFtm2, /*!< UARTx_TX pin modulated with FTM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_k24f12_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM FlexTimer x trigger y select */ -typedef enum _sim_ftm_trg_src -{ - kSimFtmTrgSrc0, /*!< FlexTimer x trigger y select 0 */ - kSimFtmTrgSrc1 /*!< FlexTimer x trigger y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_trg_src_k24f12_t; -#else -} sim_ftm_trg_src_t; -#endif - -/*! @brief SIM FlexTimer external clock select */ -typedef enum _sim_ftm_clk_sel -{ - kSimFtmClkSel0, /*!< FTM CLKIN0 pin. */ - kSimFtmClkSel1 /*!< FTM CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_clk_sel_k24f12_t; -#else -} sim_ftm_clk_sel_t; -#endif - -/*! @brief SIM FlexTimer x channel y input capture source select */ -typedef enum _sim_ftm_ch_src -{ - kSimFtmChSrc0, /*!< FlexTimer x channel y input capture source 0. */ - kSimFtmChSrc1, /*!< FlexTimer x channel y input capture source 1. */ - kSimFtmChSrc2, /*!< FlexTimer x channel y input capture source 2. */ - kSimFtmChSrc3 /*!< FlexTimer x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_ch_src_k24f12_t; -#else -} sim_ftm_ch_src_t; -#endif - -/*! @brief SIM FlexTimer x Fault y select */ -typedef enum _sim_ftm_flt_sel -{ - kSimFtmFltSel0, /*!< FlexTimer x fault y select 0 */ - kSimFtmFltSel1 /*!< FlexTimer x fault y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_flt_sel_k24f12_t; -#else -} sim_ftm_flt_sel_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_k24f12_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPM x channel y input capture source 0. */ - kSimTpmChSrc1, /*!< TPM x channel y input capture source 1. */ - kSimTpmChSrc2, /*!< TPM x channel y input capture source 2. */ - kSimTpmChSrc3, /*!< TPM x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_k24f12_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM CMT/UART pad drive strength */ -typedef enum _sim_cmtuartpad_strengh -{ - kSimCmtuartSinglePad, /*!< Single-pad drive strength for CMT IRO or UART0_TXD */ - kSimCmtuartDualPad /*!< Dual-pad drive strength for CMT IRO or UART0_TXD */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_cmtuartpad_strengh_k24f12_t; -#else -} sim_cmtuartpad_strengh_t; -#endif - -/*! @brief SIM PTD7 pad drive strength */ -typedef enum _sim_ptd7pad_strengh -{ - kSimPtd7padSinglePad, /*!< Single-pad drive strength for PTD7 */ - kSimPtd7padDualPad /*!< Dual-pad drive strength for PTD7 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ptd7pad_strengh_k24f12_t; -#else -} sim_ptd7pad_strengh_t; -#endif - -/*! @brief SIM FlexBus security level */ -typedef enum _sim_flexbus_security_level -{ - kSimFbslLevel0, /*!< FlexBus security level 0. */ - kSimFbslLevel1, /*!< FlexBus security level 1. */ - kSimFbslLevel2, /*!< FlexBus security level 2. */ - kSimFbslLevel3, /*!< FlexBus security level 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_flexbus_security_level_k24f12_t; -#else -} sim_flexbus_security_level_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateI2c2 = FSL_SIM_SCGC_BIT(1U, 6U), - kSimClockGateUart4 = FSL_SIM_SCGC_BIT(1U, 10U), - kSimClockGateUart5 = FSL_SIM_SCGC_BIT(1U, 11U), - - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(2U, 12U), - kSimClockGateDac1 = FSL_SIM_SCGC_BIT(2U, 13U), - - kSimClockGateSpi2 = FSL_SIM_SCGC_BIT(3U, 12U), - kSimClockGateSdhc0 = FSL_SIM_SCGC_BIT(3U, 17U), - kSimClockGateFtm3 = FSL_SIM_SCGC_BIT(3U, 25U), - kSimClockGateAdc1 = FSL_SIM_SCGC_BIT(3U, 27U), - - kSimClockGateEwm0 = FSL_SIM_SCGC_BIT(4U, 1U), - kSimClockGateCmt0 = FSL_SIM_SCGC_BIT(4U, 2U), - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUart3 = FSL_SIM_SCGC_BIT(4U, 13U), - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), - kSimClockGateCmp = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateFlexcan0 = FSL_SIM_SCGC_BIT(6U, 4U), - kSimClockGateRnga0 = FSL_SIM_SCGC_BIT(6U, 9U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(6U, 12U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(6U, 13U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), - kSimClockGateUsbdcd0 = FSL_SIM_SCGC_BIT(6U, 21U), - kSimClockGatePdb0 = FSL_SIM_SCGC_BIT(6U, 22U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateFtm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateFtm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateFtm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - - kSimClockGateFlexbus0 = FSL_SIM_SCGC_BIT(7U, 0U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 1U), - kSimClockGateMpu0 = FSL_SIM_SCGC_BIT(7U, 2U) -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_k24f12_t; -#else -} sim_clock_gate_name_t; -#endif - -/*! @} */ -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetSdhcSrc(SIM_Type * base, - uint32_t instance, - clock_sdhc_src_t setting) -{ - SIM_BWR_SOPT2_SDHCSRC(base, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_HAL_GetSdhcSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_sdhc_src_t)SIM_BRD_SOPT2_SDHCSRC(base); -} - - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac); - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac); - - -/*! - * @brief Set debug trace clock selection. - * - * This function sets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTraceClkSrc(SIM_Type * base, clock_trace_src_t setting) -{ - SIM_BWR_SOPT2_TRACECLKSEL(base, setting); -} - -/*! - * @brief Get debug trace clock selection. - * - * This function gets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_trace_src_t CLOCK_HAL_GetTraceClkSrc(SIM_Type * base) -{ - return (clock_trace_src_t)SIM_BRD_SOPT2_TRACECLKSEL(base); -} - - - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV2. - * - * This function sets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv2(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV2(base, setting); -} - -/*! - * @brief Get OUTDIV2. - * - * This function gets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv2(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV2(base); -} - -/*! - * @brief Set OUTDIV3. - * - * This function sets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv3(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV3(base, setting); -} - -/*! - * @brief Get OUTDIV3. - * - * This function gets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv3(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV3(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); -/*! - * @brief Gets RAM size. - * - * This function gets the RAM size. The field specifies the amount of system RAM - * available on the device. - * - * @param base Base address for current SIM instance. - * @return size RAM size on the device - */ -static inline uint32_t SIM_HAL_GetRamSize(SIM_Type * base) -{ - return SIM_BRD_SOPT1_RAMSIZE(base); -} - -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} - -/*! - * @brief Sets the PTD7 pad drive strength setting. - * - * This function controls the output drive strength of the PTD7 pin by selecting - * either one or two pads to drive it. - * - * @param base Base address for current SIM instance. - * @param setting PTD7 pad drive strength setting - * - 0: Single-pad drive strength for PTD7. - * - 1: Double pad drive strength for PTD7. - */ -static inline void SIM_HAL_SetPtd7PadDriveStrengthMode(SIM_Type * base, - sim_ptd7pad_strengh_t setting) -{ - SIM_BWR_SOPT2_PTD7PAD(base, setting); -} - -/*! - * @brief Gets the PTD7 pad drive strength setting. - * - * This function gets the PTD7 pad drive strength setting. - * - * @param base Base address for current SIM instance. - * @return setting PTD7 pad drive strength setting - */ -static inline sim_ptd7pad_strengh_t SIM_HAL_GetPtd7PadDriveStrengthMode(SIM_Type * base) -{ - return (sim_ptd7pad_strengh_t)SIM_BRD_SOPT2_PTD7PAD(base); -} - -/*! - * @brief Sets the FlexBus security level setting. - * - * This function sets the FlexBus security level setting. If the security is enabled, - * this field affects which CPU operations can access the off-chip via the FlexBus - * and DDR controller interfaces. This field has no effect if the security is not enabled. - * - * @param base Base address for current SIM instance. - * @param setting FlexBus security level setting - * - 00: All off-chip accesses (op code and data) via the FlexBus and - * DDR controller are disallowed. - * - 10: Off-chip op code accesses are disallowed. Data accesses are - * allowed. - * - 11: Off-chip op code accesses and data accesses are allowed. - */ -static inline void SIM_HAL_SetFlexbusSecurityLevelMode(SIM_Type * base, - sim_flexbus_security_level_t setting) -{ - SIM_BWR_SOPT2_FBSL(base, setting); -} - -/*! - * @brief Gets the FlexBus security level setting. - * - * This function gets the FlexBus security level setting. - * - * @param base Base address for current SIM instance. - * @return setting FlexBus security level setting - */ -static inline sim_flexbus_security_level_t SIM_HAL_GetFlexbusSecurityLevelMode(SIM_Type * base) -{ - return (sim_flexbus_security_level_t)SIM_BRD_SOPT2_FBSL(base); -} - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select); - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select); - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the FlexTimer x hardware trigger y source select setting. - * - * This function selects the source of FTMx hardware trigger y. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @param select FlexTimer x hardware trigger y - * - 0: Pre-trigger A selected for ADCx. - * - 1: Pre-trigger B selected for ADCx. - */ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select); - -/*! - * @brief Gets the FlexTimer x hardware trigger y source select setting. - * - * This function gets the FlexTimer x hardware trigger y source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @return select FlexTimer x hardware trigger y source select setting - */ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger); - -/*! - * @brief Sets the FlexTimer x external clock pin select setting. - * - * This function selects the source of FTMx external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select FTMx external clock pin select - * - 0: FTMx external clock driven by FTM CLKIN0 pin. - * - 1: FTMx external clock driven by FTM CLKIN1 pin. - */ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select); - -/*! - * @brief Gets the FlexTimer x external clock pin select setting. - * - * This function gets the FlexTimer x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select FlexTimer x external clock pin select setting - */ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the FlexTimer x channel y input capture source select setting. - * - * This function selects the FlexTimer x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y input capture source - */ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y input capture source select setting. - * - * This function gets the FlexTimer x channel y input capture - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y input capture source select setting - */ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Sets the FlexTimer x fault y select setting. - * - * This function sets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @param select FlexTimer x fault y select setting - * - 0: FlexTimer x fault y select 0. - * - 1: FlexTimer x fault y select 1. - */ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select); - -/*! - * @brief Gets the FlexTimer x fault y select setting. - * - * This function gets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @return select FlexTimer x fault y select setting - */ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault); - -/*! - * @brief Gets the Kinetis Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Family ID in the System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Family ID - */ -static inline uint32_t SIM_HAL_GetFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMILYID(base); -} - -/*! - * @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Sub-Family ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Sub-Family ID - */ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} - -/*! - * @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Series ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Series ID - */ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type * base) -{ - return SIM_BRD_SDID_SERIESID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the Kinetis Die ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Die ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Die ID - */ -static inline uint32_t SIM_HAL_GetDieId(SIM_Type * base) -{ - return SIM_BRD_SDID_DIEID(base); -} - -/*! - * @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Fam ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Fam ID - */ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the FlexNVM size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size FlexNVM Size - */ -static inline uint32_t SIM_HAL_GetFlexnvmSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_NVMSIZE(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Gets the EEProm size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the EEProm size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size EEProm Size - */ -static inline uint32_t SIM_HAL_GetEepromSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_EESIZE(base); -} - -/*! - * @brief Gets the FlexNVM partition in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM partition in the Flash Configuration Register1 - * - * @param base Base address for current SIM instance. - * @return setting FlexNVM partition setting - */ -static inline uint32_t SIM_HAL_GetFlexnvmPartition(SIM_Type * base) -{ - return SIM_BRD_FCFG1_DEPART(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the program flash in the Flash Configuration Register 2. - * - * This function gets the program flash maximum block 0 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return status program flash status - */ -static inline uint32_t SIM_HAL_GetProgramFlashCmd(SIM_Type * base) -{ - return SIM_BRD_FCFG2_PFLSH(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -/*! @}*/ -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - - -#endif /* __FSL_SIM_HAL_K24F12_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK24F25612/fsl_sim_hal_MK24F25612.c b/KSDK_1.2.0/platform/hal/src/sim/MK24F25612/fsl_sim_hal_MK24F25612.c deleted file mode 100755 index 1dafd27..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK24F25612/fsl_sim_hal_MK24F25612.c +++ /dev/null @@ -1,779 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfDiv - * Description : Gets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - case 3: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM3TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM3TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - case 3: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM3TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM3TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - case 3: - SIM_BWR_SOPT4_FTM3CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - case 3: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM3CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - SIM_BWR_SOPT4_FTM0FLT0(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0FLT1(base, select); - break; - default: - break; - } - break; - case 1: - SIM_BWR_SOPT4_FTM1FLT0(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2FLT0(base, select); - break; - case 3: - SIM_BWR_SOPT4_FTM3FLT0(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault) -{ - sim_ftm_flt_sel_t retValue = (sim_ftm_flt_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT0(base); - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT1(base); - break; - default: - break; - } - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM1FLT0(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM2FLT0(base); - break; - case 3: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM3FLT0(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK24F25612/fsl_sim_hal_MK24F25612.h b/KSDK_1.2.0/platform/hal/src/sim/MK24F25612/fsl_sim_hal_MK24F25612.h deleted file mode 100644 index 70bc295..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK24F25612/fsl_sim_hal_MK24F25612.h +++ /dev/null @@ -1,1408 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_K24F25612_H__) -#define __FSL_SIM_HAL_K24F25612_H__ - -/*! - * @addtogroup sim_hal_k24f25612 - * @{ - */ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief WDOG clock source select */ -typedef enum _clock_wdog_src_t -{ - kClockWdogSrcLpoClk, /*!< LPO */ - kClockWdogSrcAltClk /*!< Alternative clock, for this SOC it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_wdog_src_k24f25612_t; -#else -} clock_wdog_src_t; -#endif - -/*! @brief Debug trace clock source select */ -typedef enum _clock_trace_src_t -{ - kClockTraceSrcMcgoutClk, /*!< MCG out clock */ - kClockTraceSrcCoreClk /*!< core clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_trace_src_k24f25612_t; -#else -} clock_trace_src_t; -#endif - -/*! @brief PORTx digital input filter clock source select */ -typedef enum _clock_port_filter_src_t -{ - kClockPortFilterSrcBusClk, /*!< Bus clock */ - kClockPortFilterSrcLpoClk /*!< LPO */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_port_filter_src_k24f25612_t; -#else -} clock_port_filter_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCGIRCLK */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_k24f25612_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcPllFllSel /*!< Clock divider USB FS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_k24f25612_t; -#else -} clock_usbfs_src_t; -#endif - -/*! @brief FLEXCAN clock source select */ -typedef enum _clock_flexcan_src_t -{ - kClockFlexcanSrcOsc0erClk, /*!< OSCERCLK */ - kClockFlexcanSrcBusClk /*!< Bus clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_flexcan_src_k24f25612_t; -#else -} clock_flexcan_src_t; -#endif - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_k24f25612_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll = 0U, /*!< Fll clock */ - kClockPllFllSelPll = 1U, /*!< Pll0 clock */ - kClockPllFllSelIrc48M = 3U /*!< IRC48MCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_k24f25612_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_k24f25612_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCGIRCLK */ - kClockClkoutSelRtc = 5U, /*!< RTC 32k clock */ - kClockClkoutSelOsc0erClk = 6U, /*!< OSC0ERCLK */ - kClockClkoutSelIrc48M = 7U /*!< IRC48MCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_k24f25612_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz /*!< 32kHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_k24f25612_t; -#else -} clock_rtcout_src_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_k24f25612_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_k24f25612_t; -#else -} sim_usbvstby_mode_t; -#endif - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_k24f25612_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /*!< High speed comparator 0 output */ - kSimAdcTrgSelHighSpeedComp1 = 2U, /*!< High speed comparator 1 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelPit2 = 6U, /*!< PIT trigger 2 */ - kSimAdcTrgSelPit3 = 7U, /*!< PIT trigger 3 */ - kSimAdcTrgSelFtm0 = 8U, /*!< FTM0 trigger */ - kSimAdcTrgSelFtm1 = 9U, /*!< FTM1 trigger */ - kSimAdcTrgSelFtm2 = 10U, /*!< FTM2 trigger */ - kSimAdcTrgSelFtm3 = 11U, /*!< FTM3 trigger */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_k24f25612_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ - kSimUartRxsrcCmp1 /*!< CMP1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_k24f25612_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcFtm1, /*!< UARTx_TX pin modulated with FTM1 channel 0 output */ - kSimUartTxsrcFtm2 /*!< UARTx_TX pin modulated with FTM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_k24f25612_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM FlexTimer x trigger y select */ -typedef enum _sim_ftm_trg_src -{ - kSimFtmTrgSrc0, /*!< FlexTimer x trigger y select 0 */ - kSimFtmTrgSrc1 /*!< FlexTimer x trigger y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_trg_src_k24f25612_t; -#else -} sim_ftm_trg_src_t; -#endif - -/*! @brief SIM FlexTimer external clock select */ -typedef enum _sim_ftm_clk_sel -{ - kSimFtmClkSel0, /*!< FTM CLKIN0 pin. */ - kSimFtmClkSel1 /*!< FTM CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_clk_sel_k24f25612_t; -#else -} sim_ftm_clk_sel_t; -#endif - -/*! @brief SIM FlexTimer x channel y input capture source select */ -typedef enum _sim_ftm_ch_src -{ - kSimFtmChSrc0, /*!< FlexTimer x channel y input capture source 0. */ - kSimFtmChSrc1, /*!< FlexTimer x channel y input capture source 1. */ - kSimFtmChSrc2, /*!< FlexTimer x channel y input capture source 2. */ - kSimFtmChSrc3 /*!< FlexTimer x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_ch_src_k24f25612_t; -#else -} sim_ftm_ch_src_t; -#endif - -/*! @brief SIM FlexTimer x Fault y select */ -typedef enum _sim_ftm_flt_sel -{ - kSimFtmFltSel0, /*!< FlexTimer x fault y select 0 */ - kSimFtmFltSel1 /*!< FlexTimer x fault y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_flt_sel_k24f25612_t; -#else -} sim_ftm_flt_sel_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_k24f25612_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1 /*!< CMP0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_k24f25612_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM CMT/UART pad drive strength */ -typedef enum _sim_cmtuartpad_strengh -{ - kSimCmtuartSinglePad, /*!< Single-pad drive strength for CMT IRO or UART0_TXD */ - kSimCmtuartDualPad /*!< Dual-pad drive strength for CMT IRO or UART0_TXD */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_cmtuartpad_strengh_k24f25612_t; -#else -} sim_cmtuartpad_strengh_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateI2c2 = FSL_SIM_SCGC_BIT(1U, 6U), - kSimClockGateUart4 = FSL_SIM_SCGC_BIT(1U, 10U), - kSimClockGateUart5 = FSL_SIM_SCGC_BIT(1U, 11U), - - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(2U, 12U), - - kSimClockGateSpi2 = FSL_SIM_SCGC_BIT(3U, 12U), - kSimClockGateFtm3 = FSL_SIM_SCGC_BIT(3U, 25U), - kSimClockGateAdc1 = FSL_SIM_SCGC_BIT(3U, 27U), - - kSimClockGateEwm0 = FSL_SIM_SCGC_BIT(4U, 1U), - kSimClockGateCmt0 = FSL_SIM_SCGC_BIT(4U, 2U), - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUart3 = FSL_SIM_SCGC_BIT(4U, 13U), - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), - kSimClockGateCmp = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateRnga0 = FSL_SIM_SCGC_BIT(6U, 9U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(6U, 12U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(6U, 13U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), - kSimClockGateUsbdcd0 = FSL_SIM_SCGC_BIT(6U, 21U), - kSimClockGatePdb0 = FSL_SIM_SCGC_BIT(6U, 22U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateFtm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateFtm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateFtm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 1U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_k24f25612_t; -#else -} sim_clock_gate_name_t; -#endif - -/*! @}*/ -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac); - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac); - - -/*! - * @brief Set debug trace clock selection. - * - * This function sets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTraceClkSrc(SIM_Type * base, clock_trace_src_t setting) -{ - SIM_BWR_SOPT2_TRACECLKSEL(base, setting); -} - -/*! - * @brief Get debug trace clock selection. - * - * This function gets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_trace_src_t CLOCK_HAL_GetTraceClkSrc(SIM_Type * base) -{ - return (clock_trace_src_t)SIM_BRD_SOPT2_TRACECLKSEL(base); -} - - - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV2. - * - * This function sets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv2(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV2(base, setting); -} - -/*! - * @brief Get OUTDIV2. - * - * This function gets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv2(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV2(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); -/*! - * @brief Gets RAM size. - * - * This function gets the RAM size. The field specifies the amount of system RAM - * available on the device. - * - * @param base Base address for current SIM instance. - * @return size RAM size on the device - */ -static inline uint32_t SIM_HAL_GetRamSize(SIM_Type * base) -{ - return SIM_BRD_SOPT1_RAMSIZE(base); -} - -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select); - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select); - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the FlexTimer x hardware trigger y source select setting. - * - * This function selects the source of FTMx hardware trigger y. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @param select FlexTimer x hardware trigger y - * - 0: Pre-trigger A selected for ADCx. - * - 1: Pre-trigger B selected for ADCx. - */ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select); - -/*! - * @brief Gets the FlexTimer x hardware trigger y source select setting. - * - * This function gets the FlexTimer x hardware trigger y source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @return select FlexTimer x hardware trigger y source select setting - */ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger); - -/*! - * @brief Sets the FlexTimer x external clock pin select setting. - * - * This function selects the source of FTMx external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select FTMx external clock pin select - * - 0: FTMx external clock driven by FTM CLKIN0 pin. - * - 1: FTMx external clock driven by FTM CLKIN1 pin. - */ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select); - -/*! - * @brief Gets the FlexTimer x external clock pin select setting. - * - * This function gets the FlexTimer x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select FlexTimer x external clock pin select setting - */ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the FlexTimer x channel y input capture source select setting. - * - * This function selects the FlexTimer x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y input capture source - */ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y input capture source select setting. - * - * This function gets the FlexTimer x channel y input capture - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y input capture source select setting - */ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Sets the FlexTimer x fault y select setting. - * - * This function sets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @param select FlexTimer x fault y select setting - * - 0: FlexTimer x fault y select 0. - * - 1: FlexTimer x fault y select 1. - */ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select); - -/*! - * @brief Gets the FlexTimer x fault y select setting. - * - * This function gets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @return select FlexTimer x fault y select setting - */ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault); - -/*! - * @brief Gets the Kinetis Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Family ID in the System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Family ID - */ -static inline uint32_t SIM_HAL_GetFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMILYID(base); -} - -/*! - * @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Sub-Family ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Sub-Family ID - */ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} - -/*! - * @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Series ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Series ID - */ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type * base) -{ - return SIM_BRD_SDID_SERIESID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the Kinetis Die ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Die ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Die ID - */ -static inline uint32_t SIM_HAL_GetDieId(SIM_Type * base) -{ - return SIM_BRD_SDID_DIEID(base); -} - -/*! - * @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Fam ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Fam ID - */ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - - -/*! @}*/ -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - - -#endif /* __FSL_SIM_HAL_K24F25612_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK26F18/fsl_sim_hal_MK26F18.c b/KSDK_1.2.0/platform/hal/src/sim/MK26F18/fsl_sim_hal_MK26F18.c deleted file mode 100755 index 0412fe2..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK26F18/fsl_sim_hal_MK26F18.c +++ /dev/null @@ -1,1037 +0,0 @@ -/* - * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfsDiv - * Description : Gets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetPllFllDiv - * Description : Sets PLL/FLL divider setting. - * Divider output clock = Divider input clock * [ (PLLFLLFRAC+1) / (PLLFLLDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetPllFllDiv(SIM_Type * base, - uint8_t pllflldiv, - uint8_t pllfllfrac) -{ - SIM_BWR_CLKDIV3_PLLFLLDIV(base, pllflldiv); - SIM_BWR_CLKDIV3_PLLFLLFRAC(base, pllfllfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetPllFllDiv - * Description : Get PLL/FLL divider setting. - * Divider output clock = Divider input clock * [ (PLLFLLFRAC+1) / (PLLFLLDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetPllFllDiv(SIM_Type * base, - uint8_t *pllflldiv, - uint8_t *pllfllfrac) -{ - *pllflldiv = SIM_BRD_CLKDIV3_PLLFLLDIV(base); - *pllfllfrac = SIM_BRD_CLKDIV3_PLLFLLFRAC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetTraceDiv - * Description : Sets TRACECLK divider setting. - * Divider output clock = Divider input clock * [ (TRACEFRAC+1) / (TRACEDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetTraceDiv(SIM_Type * base, - uint8_t tracediv, - uint8_t tracefrac) -{ - SIM_BWR_CLKDIV4_TRACEDIV(base, tracediv); - SIM_BWR_CLKDIV4_TRACEFRAC(base, tracefrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetTraceDiv - * Description : Get TRACECLK divider setting. - * Divider output clock = Divider input clock * [ (TRACEFRAC+1) / (TRACEDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetTraceDiv(SIM_Type * base, - uint8_t *tracediv, - uint8_t *tracefrac) -{ - *tracediv = SIM_BRD_CLKDIV4_TRACEDIV(base); - *tracefrac = SIM_BRD_CLKDIV4_TRACEFRAC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV3(outdiv3); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = SIM_BRD_CLKDIV1_OUTDIV3(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - case 3: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM3TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM3TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - case 3: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM3TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM3TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - case 3: - SIM_BWR_SOPT4_FTM3CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - case 3: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM3CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM2CH1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - case 1: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/* Macro for FTMxOCHySRC. */ -#define FTM_CH_OUT_SRC_MASK(instance, channel) \ - (1U << ((((instance)>>1U)*8U) + channel + 16U)) - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChOutSrcMode - * Description : FlexTimer x channel y output source select setting. - * This function will select FlexTimer x channel y output source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_out_src_t select) -{ - assert ((0U==instance) || (3U==instance)); - assert (8U>channel); - - if (kSimFtmChOutSrc0 == select) - { - SIM_CLR_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } - else - { - SIM_SET_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChOutSrcMode - * Description : Get FlexTimer x channel y output source select setting - * This function will get FlexTimer x channel y output source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_out_src_t SIM_HAL_GetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - assert ((0U==instance) || (3U==instance)); - assert (8U>channel); - return (sim_ftm_ch_out_src_t) - (SIM_RD_SOPT8(base) & FTM_CH_OUT_SRC_MASK(instance, channel)); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmSyncCmd - * Description : Set FTMxSYNCBIT - * This function sets FlexTimer x hardware trigger 0 software synchronization. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmSyncCmd(SIM_Type * base, uint32_t instance, bool sync) -{ - assert (instance < FTM_INSTANCE_COUNT); - if (sync) - { - SIM_SET_SOPT8(base, (1U< -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfDiv - * Description : Gets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} -#endif - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV3(outdiv3); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = SIM_BRD_CLKDIV1_OUTDIV3(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - SIM_BWR_SOPT4_FTM0FLT0(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0FLT1(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM0FLT2(base, select); - break; - default: - break; - } - break; - case 1: - SIM_BWR_SOPT4_FTM1FLT0(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2FLT0(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault) -{ - sim_ftm_flt_sel_t retValue = (sim_ftm_flt_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT0(base); - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT1(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT2(base); - break; - default: - break; - } - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM1FLT0(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM2FLT0(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK30D10/fsl_sim_hal_MK30D10.h b/KSDK_1.2.0/platform/hal/src/sim/MK30D10/fsl_sim_hal_MK30D10.h deleted file mode 100644 index be62119..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK30D10/fsl_sim_hal_MK30D10.h +++ /dev/null @@ -1,1731 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_K30D10_H__) -#define __FSL_SIM_HAL_K30D10_H__ - - -/*! - * @addtogroup sim_hal_k30d10 - * @{ - */ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief WDOG clock source select */ -typedef enum _clock_wdog_src_t -{ - kClockWdogSrcLpoClk, /*!< LPO */ - kClockWdogSrcAltClk /*!< Alternative clock, for K30D10 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_wdog_src_k30d10_t; -#else -} clock_wdog_src_t; -#endif - -/*! @brief Debug trace clock source select */ -typedef enum _clock_trace_src_t -{ - kClockTraceSrcMcgoutClk, /*!< MCG out clock */ - kClockTraceSrcCoreClk /*!< core clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_trace_src_k30d10_t; -#else -} clock_trace_src_t; -#endif - -/*! @brief PORTx digital input filter clock source select */ -typedef enum _clock_port_filter_src_t -{ - kClockPortFilterSrcBusClk, /*!< Bus clock */ - kClockPortFilterSrcLpoClk /*!< LPO */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_port_filter_src_k30d10_t; -#else -} clock_port_filter_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG IRC clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_k30d10_t; -#else -} clock_lptmr_src_t; -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! @brief SIM timestamp clock source */ -typedef enum _clock_time_src -{ - kClockTimeSrcCoreSysClk, /*!< Core/system clock */ - kClockTimeSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTimeSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTimeSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_time_src_k30d10_t; -#else -} clock_time_src_t; -#endif -#endif // FSL_FEATURE_SOC_ENET_COUNT - -/*! @brief SIM RMII clock source */ -typedef enum _clock_rmii_src -{ - kClockRmiiSrcExtalClk, /*!< EXTAL Clock */ - kClockRmiiSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rmii_src_k30d10_t; -#else -} clock_rmii_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcPllFllSel, /*!< Clock divider USB FS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_k30d10_t; -#else -} clock_usbfs_src_t; -#endif -#endif // FSL_FEATURE_SOC_USB_COUNT - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*! @brief FLEXCAN clock source select */ -typedef enum _clock_flexcan_src_t -{ - kClockFlexcanSrcOsc0erClk, /*!< OSCERCLK */ - kClockFlexcanSrcBusClk /*!< Bus clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_flexcan_src_k30d10_t; -#else -} clock_flexcan_src_t; -#endif -#endif // FSL_FEATURE_SOC_FLEXCAN_COUNT - -/*! @brief SDHC clock source */ -typedef enum _clock_sdhc_src -{ - kClockSdhcSrcCoreSysClk, /*!< Core/system clock */ - kClockSdhcSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockSdhcSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockSdhcSrcExt /*!< External bypass clock (SDHC0_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sdhc_src_k30d10_t; -#else -} clock_sdhc_src_t; -#endif - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_k30d10_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief TSI Active Mode clock source */ -typedef enum _clock_tsi_active_mode_src -{ - kClockTsiActiveSrcBusClk, /*!< Bus clock */ - kClockTsiActiveSrcMcgIrClk, /*!< MCG IRC clock */ - kClockTsiActiveSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tsi_active_mode_src_k30d10_t; -#else -} clock_tsi_active_mode_src_t; -#endif - -/*! @brief TSI Low-power Mode clock source */ -typedef enum _clock_tsi_lp_mode_src -{ - kClockTsiLpSrcLpoClk, /*!< LPO clock */ - kClockTsiLpSrcEr32kClk /*!< ERCLK32K clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tsi_lp_mode_src_k30d10_t; -#else -} clock_tsi_lp_mode_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll = 0U, /*!< Fll clock */ - kClockPllFllSelPll = 1U, /*!< Pll0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_k30d10_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_k30d10_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlexbusClk = 0U, /*!< Flexbus clock */ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCG out clock */ - kClockClkoutSelRtc32kClk = 5U, /*!< RTC 32k clock */ - kClockClkoutSelOsc0erClk = 6U /*!< OSCERCLK0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_k30d10_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz /*!< 32kHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_k30d10_t; -#else -} clock_rtcout_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_k30d10_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_k30d10_t; -#else -} sim_usbvstby_mode_t; -#endif -#endif // FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_k30d10_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /*!< High speed comparator 0 output */ - kSimAdcTrgSelHighSpeedComp1 = 2U, /*!< High speed comparator 1 output */ - kSimAdcTrgSelHighSpeedComp2 = 3U, /*!< High speed comparator 2 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelPit2 = 6U, /*!< PIT trigger 2 */ - kSimAdcTrgSelPit3 = 7U, /*!< PIT trigger 3 */ - kSimAdcTrgSelFtm0 = 8U, /*!< FTM0 trigger */ - kSimAdcTrgSelFtm1 = 9U, /*!< FTM1 trigger */ - kSimAdcTrgSelFtm2 = 10U, /*!< FTM2 trigger */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_k30d10_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ - kSimUartRxsrcCmp1, /*!< CMP1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_k30d10_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcFtm1, /*!< UARTx_TX pin modulated with FTM1 channel 0 output */ - kSimUartTxsrcFtm2 /*!< UARTx_TX pin modulated with FTM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_k30d10_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM FlexTimer x trigger y select */ -typedef enum _sim_ftm_trg_src -{ - kSimFtmTrgSrc0, /*!< FlexTimer x trigger y select 0 */ - kSimFtmTrgSrc1 /*!< FlexTimer x trigger y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_trg_src_k30d10_t; -#else -} sim_ftm_trg_src_t; -#endif - -/*! @brief SIM FlexTimer external clock select */ -typedef enum _sim_ftm_clk_sel -{ - kSimFtmClkSel0, /*!< FTM CLKIN0 pin. */ - kSimFtmClkSel1 /*!< FTM CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_clk_sel_k30d10_t; -#else -} sim_ftm_clk_sel_t; -#endif - -/*! @brief SIM FlexTimer x channel y input capture source select */ -typedef enum _sim_ftm_ch_src -{ - kSimFtmChSrc0, /*!< FlexTimer x channel y input capture source 0. */ - kSimFtmChSrc1, /*!< FlexTimer x channel y input capture source 1. */ - kSimFtmChSrc2, /*!< FlexTimer x channel y input capture source 2. */ - kSimFtmChSrc3 /*!< FlexTimer x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_ch_src_k30d10_t; -#else -} sim_ftm_ch_src_t; -#endif - -/*! @brief SIM FlexTimer x Fault y select */ -typedef enum _sim_ftm_flt_sel -{ - kSimFtmFltSel0, /*!< FlexTimer x fault y select 0 */ - kSimFtmFltSel1 /*!< FlexTimer x fault y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_flt_sel_k30d10_t; -#else -} sim_ftm_flt_sel_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_k30d10_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1 /*!< CMP0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_k30d10_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM CMT/UART pad drive strength */ -typedef enum _sim_cmtuartpad_strengh -{ - kSimCmtuartSinglePad, /*!< Single-pad drive strength for CMT IRO or UART0_TXD */ - kSimCmtuartDualPad /*!< Dual-pad drive strength for CMT IRO or UART0_TXD */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_cmtuartpad_strengh_k30d10_t; -#else -} sim_cmtuartpad_strengh_t; -#endif - -/*! @brief SIM PTD7 pad drive strength */ -typedef enum _sim_ptd7pad_strengh -{ - kSimPtd7padSinglePad, /*!< Single-pad drive strength for PTD7 */ - kSimPtd7padDualPad /*!< Dual-pad drive strength for PTD7 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ptd7pad_strengh_k30d10_t; -#else -} sim_ptd7pad_strengh_t; -#endif - -/*! @brief SIM FlexBus security level */ -typedef enum _sim_flexbus_security_level -{ - kSimFbslLevel0, /*!< FlexBus security level 0. */ - kSimFbslLevel1, /*!< FlexBus security level 1. */ - kSimFbslLevel2, /*!< FlexBus security level 2. */ - kSimFbslLevel3, /*!< FlexBus security level 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_flexbus_security_level_k30d10_t; -#else -} sim_flexbus_security_level_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateUart4 = FSL_SIM_SCGC_BIT(1U, 10U), - kSimClockGateUart5 = FSL_SIM_SCGC_BIT(1U, 11U), -#if FSL_FEATURE_SOC_OPAMP_COUNT - kSimClockGateOpamp = FSL_SIM_SCGC_BIT(1U, 21U), -#endif -#if FSL_FEATURE_SOC_TRIAMP_COUNT - kSimClockGateTriamp = FSL_SIM_SCGC_BIT(1U, 24U), -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT - kSimClockGateEnet0 = FSL_SIM_SCGC_BIT(2U, 0U), -#endif - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(2U, 12U), - kSimClockGateDac1 = FSL_SIM_SCGC_BIT(2U, 13U), - -#if FSL_FEATURE_SOC_RNG_COUNT - kSimClockGateRnga0 = FSL_SIM_SCGC_BIT(3U, 0U), -#endif -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - kSimClockGateFlexcan1 = FSL_SIM_SCGC_BIT(3U, 4U), -#endif - kSimClockGateSpi2 = FSL_SIM_SCGC_BIT(3U, 12U), - kSimClockGateSdhc0 = FSL_SIM_SCGC_BIT(3U, 17U), - kSimClockGateFtm2 = FSL_SIM_SCGC_BIT(3U, 24U), - kSimClockGateAdc1 = FSL_SIM_SCGC_BIT(3U, 27U), -#if FSL_FEATURE_SOC_LCD_COUNT - kSimClockGateSlcd0 = FSL_SIM_SCGC_BIT(3U, 30U), -#endif - - kSimClockGateEwm0 = FSL_SIM_SCGC_BIT(4U, 1U), - kSimClockGateCmt0 = FSL_SIM_SCGC_BIT(4U, 2U), - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUart3 = FSL_SIM_SCGC_BIT(4U, 13U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), -#endif - kSimClockGateCmp = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateLlwu0 = FSL_SIM_SCGC_BIT(4U, 28U), - - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGateTsi0 = FSL_SIM_SCGC_BIT(5U, 5U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - kSimClockGateFlexcan0 = FSL_SIM_SCGC_BIT(6U, 4U), -#endif - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(6U, 12U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(6U, 13U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbdcd0 = FSL_SIM_SCGC_BIT(6U, 21U), -#endif - kSimClockGatePdb0 = FSL_SIM_SCGC_BIT(6U, 22U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateFtm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateFtm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - - kSimClockGateFlexbus0 = FSL_SIM_SCGC_BIT(7U, 0U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 1U), - kSimClockGateMpu0 = FSL_SIM_SCGC_BIT(7U, 2U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_k30d10_t; -#else -} sim_clock_gate_name_t; -#endif - -/*! @} */ -/******************************************************************************* - * API - ******************************************************************************/ - - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetSdhcSrc(SIM_Type * base, - uint32_t instance, - clock_sdhc_src_t setting) -{ - SIM_BWR_SOPT2_SDHCSRC(base, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_HAL_GetSdhcSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_sdhc_src_t)SIM_BRD_SOPT2_SDHCSRC(base); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTimeSrc(SIM_Type * base, - uint32_t instance, - clock_time_src_t setting) -{ - SIM_BWR_SOPT2_TIMESRC(base, setting); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_time_src_t CLOCK_HAL_GetTimeSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_time_src_t)SIM_BRD_SOPT2_TIMESRC(base); -} - -/*! - * @brief Set the Ethernet RMII interface clock source selection. - * - * This function sets the Ethernet RMII interface clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRmiiSrc(SIM_Type * base, - uint32_t instance, - clock_rmii_src_t setting) -{ - SIM_BWR_SOPT2_RMIISRC(base, setting); -} - -/*! - * @brief Get the Ethernet RMII interface clock source selection. - * - * This function gets the Ethernet RMII interface clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_rmii_src_t CLOCK_HAL_GetRmiiSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_rmii_src_t)SIM_BRD_SOPT2_RMIISRC(base); -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} -#endif - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set debug trace clock selection. - * - * This function sets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTraceClkSrc(SIM_Type * base, clock_trace_src_t setting) -{ - SIM_BWR_SOPT2_TRACECLKSEL(base, setting); -} - -/*! - * @brief Get debug trace clock selection. - * - * This function gets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_trace_src_t CLOCK_HAL_GetTraceClkSrc(SIM_Type * base) -{ - return (clock_trace_src_t)SIM_BRD_SOPT2_TRACECLKSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV2. - * - * This function sets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv2(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV2(base, setting); -} - -/*! - * @brief Get OUTDIV2. - * - * This function gets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv2(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV2(base); -} - -/*! - * @brief Set OUTDIV3. - * - * This function sets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv3(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV3(base, setting); -} - -/*! - * @brief Get OUTDIV3. - * - * This function gets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv3(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV3(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac); - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac); -#endif - -/*! - * @brief Gets RAM size. - * - * This function gets the RAM size. The field specifies the amount of system RAM - * available on the device. - * - * @param base Base address for current SIM instance. - * @return size RAM size on the device - */ -static inline uint32_t SIM_HAL_GetRamSize(SIM_Type * base) -{ - return SIM_BRD_SOPT1_RAMSIZE(base); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif - -/*! - * @brief Sets the PTD7 pad drive strength setting. - * - * This function controls the output drive strength of the PTD7 pin by selecting - * either one or two pads to drive it. - * - * @param base Base address for current SIM instance. - * @param setting PTD7 pad drive strength setting - * - 0: Single-pad drive strength for PTD7. - * - 1: Double pad drive strength for PTD7. - */ -static inline void SIM_HAL_SetPtd7PadDriveStrengthMode(SIM_Type * base, - sim_ptd7pad_strengh_t setting) -{ - SIM_BWR_SOPT2_PTD7PAD(base, setting); -} - -/*! - * @brief Gets the PTD7 pad drive strength setting. - * - * This function gets the PTD7 pad drive strength setting. - * - * @param base Base address for current SIM instance. - * @return setting PTD7 pad drive strength setting - */ -static inline sim_ptd7pad_strengh_t SIM_HAL_GetPtd7PadDriveStrengthMode(SIM_Type * base) -{ - return (sim_ptd7pad_strengh_t)SIM_BRD_SOPT2_PTD7PAD(base); -} - -/*! - * @brief Sets the FlexBus security level setting. - * - * This function sets the FlexBus security level setting. If the security is enabled, - * this field affects which CPU operations can access the off-chip via the FlexBus - * and DDR controller interfaces. This field has no effect if the security is not enabled. - * - * @param base Base address for current SIM instance. - * @param setting FlexBus security level setting - * - 00: All off-chip accesses (op code and data) via the FlexBus and - * DDR controller are disallowed. - * - 10: Off-chip op code accesses are disallowed. Data accesses are - * allowed. - * - 11: Off-chip op code accesses and data accesses are allowed. - */ -static inline void SIM_HAL_SetFlexbusSecurityLevelMode(SIM_Type * base, - sim_flexbus_security_level_t setting) -{ - SIM_BWR_SOPT2_FBSL(base, setting); -} - -/*! - * @brief Gets the FlexBus security level setting. - * - * This function gets the FlexBus security level setting. - * - * @param base Base address for current SIM instance. - * @return setting FlexBus security level setting - */ -static inline sim_flexbus_security_level_t SIM_HAL_GetFlexbusSecurityLevelMode(SIM_Type * base) -{ - return (sim_flexbus_security_level_t)SIM_BRD_SOPT2_FBSL(base); -} - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select); - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select); - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the FlexTimer x hardware trigger y source select setting. - * - * This function selects the source of FTMx hardware trigger y. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @param select FlexTimer x hardware trigger y - * - 0: Pre-trigger A selected for ADCx. - * - 1: Pre-trigger B selected for ADCx. - */ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select); - -/*! - * @brief Gets the FlexTimer x hardware trigger y source select setting. - * - * This function gets the FlexTimer x hardware trigger y source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @return select FlexTimer x hardware trigger y source select setting - */ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger); - -/*! - * @brief Sets the FlexTimer x external clock pin select setting. - * - * This function selects the source of FTMx external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select FTMx external clock pin select - * - 0: FTMx external clock driven by FTM CLKIN0 pin. - * - 1: FTMx external clock driven by FTM CLKIN1 pin. - */ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select); - -/*! - * @brief Gets the FlexTimer x external clock pin select setting. - * - * This function gets the FlexTimer x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select FlexTimer x external clock pin select setting - */ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the FlexTimer x channel y input capture source select setting. - * - * This function selects the FlexTimer x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y input capture source - */ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y input capture source select setting. - * - * This function gets the FlexTimer x channel y input capture - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y input capture source select setting - */ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Sets the FlexTimer x fault y select setting. - * - * This function sets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @param select FlexTimer x fault y select setting - * - 0: FlexTimer x fault y select 0. - * - 1: FlexTimer x fault y select 1. - */ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select); - -/*! - * @brief Gets the FlexTimer x fault y select setting. - * - * This function gets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @return select FlexTimer x fault y select setting - */ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault); - -/*! - * @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Fam ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Fam ID - */ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the FlexNVM size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size FlexNVM Size - */ -static inline uint32_t SIM_HAL_GetFlexnvmSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_NVMSIZE(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Gets the EEProm size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the EEProm size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size EEProm Size - */ -static inline uint32_t SIM_HAL_GetEepromSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_EESIZE(base); -} - -/*! - * @brief Gets the FlexNVM partition in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM partition in the Flash Configuration Register1 - * - * @param base Base address for current SIM instance. - * @return setting FlexNVM partition setting - */ -static inline uint32_t SIM_HAL_GetFlexnvmPartition(SIM_Type * base) -{ - return SIM_BRD_FCFG1_DEPART(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -/*! - * @brief Gets the program flash in the Flash Configuration Register 2. - * - * This function gets the program flash maximum block 0 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return status program flash status - */ -static inline uint32_t SIM_HAL_GetProgramFlashCmd(SIM_Type * base) -{ - return SIM_BRD_FCFG2_PFLSH(base); -} - -/*! - * @brief Gets the Swap program flash flag in the Flash Configuration Register 2. - * - * This function gets the Swap program flash flag in the Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return status - Swap program flash flag(Active or Inactive) - */ -static inline bool SIM_HAL_GetSwapProgramFlash(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG2_SWAPPFLSH(base); -} - - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ -/*! @}*/ - - -#endif /* __FSL_SIM_HAL_K30D10_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK40D10/fsl_sim_hal_MK40D10.c b/KSDK_1.2.0/platform/hal/src/sim/MK40D10/fsl_sim_hal_MK40D10.c deleted file mode 100755 index 46e1ed3..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK40D10/fsl_sim_hal_MK40D10.c +++ /dev/null @@ -1,750 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfDiv - * Description : Gets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} -#endif - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV3(outdiv3); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = SIM_BRD_CLKDIV1_OUTDIV3(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - SIM_BWR_SOPT4_FTM0FLT0(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0FLT1(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM0FLT2(base, select); - break; - default: - break; - } - break; - case 1: - SIM_BWR_SOPT4_FTM1FLT0(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2FLT0(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault) -{ - sim_ftm_flt_sel_t retValue = (sim_ftm_flt_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT0(base); - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT1(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT2(base); - break; - default: - break; - } - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM1FLT0(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM2FLT0(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK40D10/fsl_sim_hal_MK40D10.h b/KSDK_1.2.0/platform/hal/src/sim/MK40D10/fsl_sim_hal_MK40D10.h deleted file mode 100644 index 69c80fb..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK40D10/fsl_sim_hal_MK40D10.h +++ /dev/null @@ -1,1731 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_K40D10_H__) -#define __FSL_SIM_HAL_K40D10_H__ - - -/*! - * @addtogroup sim_hal_k40d10 - * @{ - */ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief WDOG clock source select */ -typedef enum _clock_wdog_src_t -{ - kClockWdogSrcLpoClk, /*!< LPO */ - kClockWdogSrcAltClk /*!< Alternative clock, for K40D10 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_wdog_src_k40d10_t; -#else -} clock_wdog_src_t; -#endif - -/*! @brief Debug trace clock source select */ -typedef enum _clock_trace_src_t -{ - kClockTraceSrcMcgoutClk, /*!< MCG out clock */ - kClockTraceSrcCoreClk /*!< core clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_trace_src_k40d10_t; -#else -} clock_trace_src_t; -#endif - -/*! @brief PORTx digital input filter clock source select */ -typedef enum _clock_port_filter_src_t -{ - kClockPortFilterSrcBusClk, /*!< Bus clock */ - kClockPortFilterSrcLpoClk /*!< LPO */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_port_filter_src_k40d10_t; -#else -} clock_port_filter_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG IRC clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_k40d10_t; -#else -} clock_lptmr_src_t; -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! @brief SIM timestamp clock source */ -typedef enum _clock_time_src -{ - kClockTimeSrcCoreSysClk, /*!< Core/system clock */ - kClockTimeSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTimeSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTimeSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_time_src_k40d10_t; -#else -} clock_time_src_t; -#endif -#endif // FSL_FEATURE_SOC_ENET_COUNT - -/*! @brief SIM RMII clock source */ -typedef enum _clock_rmii_src -{ - kClockRmiiSrcExtalClk, /*!< EXTAL Clock */ - kClockRmiiSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rmii_src_k40d10_t; -#else -} clock_rmii_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcPllFllSel, /*!< Clock divider USB FS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_k40d10_t; -#else -} clock_usbfs_src_t; -#endif -#endif // FSL_FEATURE_SOC_USB_COUNT - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*! @brief FLEXCAN clock source select */ -typedef enum _clock_flexcan_src_t -{ - kClockFlexcanSrcOsc0erClk, /*!< OSCERCLK */ - kClockFlexcanSrcBusClk /*!< Bus clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_flexcan_src_k40d10_t; -#else -} clock_flexcan_src_t; -#endif -#endif // FSL_FEATURE_SOC_FLEXCAN_COUNT - -/*! @brief SDHC clock source */ -typedef enum _clock_sdhc_src -{ - kClockSdhcSrcCoreSysClk, /*!< Core/system clock */ - kClockSdhcSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockSdhcSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockSdhcSrcExt /*!< External bypass clock (SDHC0_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sdhc_src_k40d10_t; -#else -} clock_sdhc_src_t; -#endif - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_k40d10_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief TSI Active Mode clock source */ -typedef enum _clock_tsi_active_mode_src -{ - kClockTsiActiveSrcBusClk, /*!< Bus clock */ - kClockTsiActiveSrcMcgIrClk, /*!< MCG IRC clock */ - kClockTsiActiveSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tsi_active_mode_src_k40d10_t; -#else -} clock_tsi_active_mode_src_t; -#endif - -/*! @brief TSI Low-power Mode clock source */ -typedef enum _clock_tsi_lp_mode_src -{ - kClockTsiLpSrcLpoClk, /*!< LPO clock */ - kClockTsiLpSrcEr32kClk /*!< ERCLK32K clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tsi_lp_mode_src_k40d10_t; -#else -} clock_tsi_lp_mode_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll = 0U, /*!< Fll clock */ - kClockPllFllSelPll = 1U, /*!< Pll0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_k40d10_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_k40d10_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlexbusClk = 0U, /*!< Flexbus clock */ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCG out clock */ - kClockClkoutSelRtc32kClk = 5U, /*!< RTC 32k clock */ - kClockClkoutSelOsc0erClk = 6U /*!< OSCERCLK0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_k40d10_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz /*!< 32kHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_k40d10_t; -#else -} clock_rtcout_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_k40d10_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_k40d10_t; -#else -} sim_usbvstby_mode_t; -#endif -#endif // FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_k40d10_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /*!< High speed comparator 0 output */ - kSimAdcTrgSelHighSpeedComp1 = 2U, /*!< High speed comparator 1 output */ - kSimAdcTrgSelHighSpeedComp2 = 3U, /*!< High speed comparator 2 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelPit2 = 6U, /*!< PIT trigger 2 */ - kSimAdcTrgSelPit3 = 7U, /*!< PIT trigger 3 */ - kSimAdcTrgSelFtm0 = 8U, /*!< FTM0 trigger */ - kSimAdcTrgSelFtm1 = 9U, /*!< FTM1 trigger */ - kSimAdcTrgSelFtm2 = 10U, /*!< FTM2 trigger */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_k40d10_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ - kSimUartRxsrcCmp1, /*!< CMP1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_k40d10_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcFtm1, /*!< UARTx_TX pin modulated with FTM1 channel 0 output */ - kSimUartTxsrcFtm2 /*!< UARTx_TX pin modulated with FTM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_k40d10_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM FlexTimer x trigger y select */ -typedef enum _sim_ftm_trg_src -{ - kSimFtmTrgSrc0, /*!< FlexTimer x trigger y select 0 */ - kSimFtmTrgSrc1 /*!< FlexTimer x trigger y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_trg_src_k40d10_t; -#else -} sim_ftm_trg_src_t; -#endif - -/*! @brief SIM FlexTimer external clock select */ -typedef enum _sim_ftm_clk_sel -{ - kSimFtmClkSel0, /*!< FTM CLKIN0 pin. */ - kSimFtmClkSel1 /*!< FTM CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_clk_sel_k40d10_t; -#else -} sim_ftm_clk_sel_t; -#endif - -/*! @brief SIM FlexTimer x channel y input capture source select */ -typedef enum _sim_ftm_ch_src -{ - kSimFtmChSrc0, /*!< FlexTimer x channel y input capture source 0. */ - kSimFtmChSrc1, /*!< FlexTimer x channel y input capture source 1. */ - kSimFtmChSrc2, /*!< FlexTimer x channel y input capture source 2. */ - kSimFtmChSrc3 /*!< FlexTimer x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_ch_src_k40d10_t; -#else -} sim_ftm_ch_src_t; -#endif - -/*! @brief SIM FlexTimer x Fault y select */ -typedef enum _sim_ftm_flt_sel -{ - kSimFtmFltSel0, /*!< FlexTimer x fault y select 0 */ - kSimFtmFltSel1 /*!< FlexTimer x fault y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_flt_sel_k40d10_t; -#else -} sim_ftm_flt_sel_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_k40d10_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1 /*!< CMP0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_k40d10_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM CMT/UART pad drive strength */ -typedef enum _sim_cmtuartpad_strengh -{ - kSimCmtuartSinglePad, /*!< Single-pad drive strength for CMT IRO or UART0_TXD */ - kSimCmtuartDualPad /*!< Dual-pad drive strength for CMT IRO or UART0_TXD */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_cmtuartpad_strengh_k40d10_t; -#else -} sim_cmtuartpad_strengh_t; -#endif - -/*! @brief SIM PTD7 pad drive strength */ -typedef enum _sim_ptd7pad_strengh -{ - kSimPtd7padSinglePad, /*!< Single-pad drive strength for PTD7 */ - kSimPtd7padDualPad /*!< Dual-pad drive strength for PTD7 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ptd7pad_strengh_k40d10_t; -#else -} sim_ptd7pad_strengh_t; -#endif - -/*! @brief SIM FlexBus security level */ -typedef enum _sim_flexbus_security_level -{ - kSimFbslLevel0, /*!< FlexBus security level 0. */ - kSimFbslLevel1, /*!< FlexBus security level 1. */ - kSimFbslLevel2, /*!< FlexBus security level 2. */ - kSimFbslLevel3, /*!< FlexBus security level 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_flexbus_security_level_k40d10_t; -#else -} sim_flexbus_security_level_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateUart4 = FSL_SIM_SCGC_BIT(1U, 10U), - kSimClockGateUart5 = FSL_SIM_SCGC_BIT(1U, 11U), -#if FSL_FEATURE_SOC_OPAMP_COUNT - kSimClockGateOpamp = FSL_SIM_SCGC_BIT(1U, 21U), -#endif -#if FSL_FEATURE_SOC_TRIAMP_COUNT - kSimClockGateTriamp = FSL_SIM_SCGC_BIT(1U, 24U), -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT - kSimClockGateEnet0 = FSL_SIM_SCGC_BIT(2U, 0U), -#endif - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(2U, 12U), - kSimClockGateDac1 = FSL_SIM_SCGC_BIT(2U, 13U), - -#if FSL_FEATURE_SOC_RNG_COUNT - kSimClockGateRnga0 = FSL_SIM_SCGC_BIT(3U, 0U), -#endif -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - kSimClockGateFlexcan1 = FSL_SIM_SCGC_BIT(3U, 4U), -#endif - kSimClockGateSpi2 = FSL_SIM_SCGC_BIT(3U, 12U), - kSimClockGateSdhc0 = FSL_SIM_SCGC_BIT(3U, 17U), - kSimClockGateFtm2 = FSL_SIM_SCGC_BIT(3U, 24U), - kSimClockGateAdc1 = FSL_SIM_SCGC_BIT(3U, 27U), -#if FSL_FEATURE_SOC_LCD_COUNT - kSimClockGateSlcd0 = FSL_SIM_SCGC_BIT(3U, 30U), -#endif - - kSimClockGateEwm0 = FSL_SIM_SCGC_BIT(4U, 1U), - kSimClockGateCmt0 = FSL_SIM_SCGC_BIT(4U, 2U), - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUart3 = FSL_SIM_SCGC_BIT(4U, 13U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), -#endif - kSimClockGateCmp = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateLlwu0 = FSL_SIM_SCGC_BIT(4U, 28U), - - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGateTsi0 = FSL_SIM_SCGC_BIT(5U, 5U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - kSimClockGateFlexcan0 = FSL_SIM_SCGC_BIT(6U, 4U), -#endif - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(6U, 12U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(6U, 13U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbdcd0 = FSL_SIM_SCGC_BIT(6U, 21U), -#endif - kSimClockGatePdb0 = FSL_SIM_SCGC_BIT(6U, 22U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateFtm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateFtm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - - kSimClockGateFlexbus0 = FSL_SIM_SCGC_BIT(7U, 0U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 1U), - kSimClockGateMpu0 = FSL_SIM_SCGC_BIT(7U, 2U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_k40d10_t; -#else -} sim_clock_gate_name_t; -#endif - -/*! @} */ -/******************************************************************************* - * API - ******************************************************************************/ - - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetSdhcSrc(SIM_Type * base, - uint32_t instance, - clock_sdhc_src_t setting) -{ - SIM_BWR_SOPT2_SDHCSRC(base, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_HAL_GetSdhcSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_sdhc_src_t)SIM_BRD_SOPT2_SDHCSRC(base); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTimeSrc(SIM_Type * base, - uint32_t instance, - clock_time_src_t setting) -{ - SIM_BWR_SOPT2_TIMESRC(base, setting); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_time_src_t CLOCK_HAL_GetTimeSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_time_src_t)SIM_BRD_SOPT2_TIMESRC(base); -} - -/*! - * @brief Set the Ethernet RMII interface clock source selection. - * - * This function sets the Ethernet RMII interface clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRmiiSrc(SIM_Type * base, - uint32_t instance, - clock_rmii_src_t setting) -{ - SIM_BWR_SOPT2_RMIISRC(base, setting); -} - -/*! - * @brief Get the Ethernet RMII interface clock source selection. - * - * This function gets the Ethernet RMII interface clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_rmii_src_t CLOCK_HAL_GetRmiiSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_rmii_src_t)SIM_BRD_SOPT2_RMIISRC(base); -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} -#endif - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set debug trace clock selection. - * - * This function sets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTraceClkSrc(SIM_Type * base, clock_trace_src_t setting) -{ - SIM_BWR_SOPT2_TRACECLKSEL(base, setting); -} - -/*! - * @brief Get debug trace clock selection. - * - * This function gets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_trace_src_t CLOCK_HAL_GetTraceClkSrc(SIM_Type * base) -{ - return (clock_trace_src_t)SIM_BRD_SOPT2_TRACECLKSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV2. - * - * This function sets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv2(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV2(base, setting); -} - -/*! - * @brief Get OUTDIV2. - * - * This function gets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv2(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV2(base); -} - -/*! - * @brief Set OUTDIV3. - * - * This function sets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv3(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV3(base, setting); -} - -/*! - * @brief Get OUTDIV3. - * - * This function gets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv3(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV3(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac); - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac); -#endif - -/*! - * @brief Gets RAM size. - * - * This function gets the RAM size. The field specifies the amount of system RAM - * available on the device. - * - * @param base Base address for current SIM instance. - * @return size RAM size on the device - */ -static inline uint32_t SIM_HAL_GetRamSize(SIM_Type * base) -{ - return SIM_BRD_SOPT1_RAMSIZE(base); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif - -/*! - * @brief Sets the PTD7 pad drive strength setting. - * - * This function controls the output drive strength of the PTD7 pin by selecting - * either one or two pads to drive it. - * - * @param base Base address for current SIM instance. - * @param setting PTD7 pad drive strength setting - * - 0: Single-pad drive strength for PTD7. - * - 1: Double pad drive strength for PTD7. - */ -static inline void SIM_HAL_SetPtd7PadDriveStrengthMode(SIM_Type * base, - sim_ptd7pad_strengh_t setting) -{ - SIM_BWR_SOPT2_PTD7PAD(base, setting); -} - -/*! - * @brief Gets the PTD7 pad drive strength setting. - * - * This function gets the PTD7 pad drive strength setting. - * - * @param base Base address for current SIM instance. - * @return setting PTD7 pad drive strength setting - */ -static inline sim_ptd7pad_strengh_t SIM_HAL_GetPtd7PadDriveStrengthMode(SIM_Type * base) -{ - return (sim_ptd7pad_strengh_t)SIM_BRD_SOPT2_PTD7PAD(base); -} - -/*! - * @brief Sets the FlexBus security level setting. - * - * This function sets the FlexBus security level setting. If the security is enabled, - * this field affects which CPU operations can access the off-chip via the FlexBus - * and DDR controller interfaces. This field has no effect if the security is not enabled. - * - * @param base Base address for current SIM instance. - * @param setting FlexBus security level setting - * - 00: All off-chip accesses (op code and data) via the FlexBus and - * DDR controller are disallowed. - * - 10: Off-chip op code accesses are disallowed. Data accesses are - * allowed. - * - 11: Off-chip op code accesses and data accesses are allowed. - */ -static inline void SIM_HAL_SetFlexbusSecurityLevelMode(SIM_Type * base, - sim_flexbus_security_level_t setting) -{ - SIM_BWR_SOPT2_FBSL(base, setting); -} - -/*! - * @brief Gets the FlexBus security level setting. - * - * This function gets the FlexBus security level setting. - * - * @param base Base address for current SIM instance. - * @return setting FlexBus security level setting - */ -static inline sim_flexbus_security_level_t SIM_HAL_GetFlexbusSecurityLevelMode(SIM_Type * base) -{ - return (sim_flexbus_security_level_t)SIM_BRD_SOPT2_FBSL(base); -} - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select); - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select); - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the FlexTimer x hardware trigger y source select setting. - * - * This function selects the source of FTMx hardware trigger y. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @param select FlexTimer x hardware trigger y - * - 0: Pre-trigger A selected for ADCx. - * - 1: Pre-trigger B selected for ADCx. - */ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select); - -/*! - * @brief Gets the FlexTimer x hardware trigger y source select setting. - * - * This function gets the FlexTimer x hardware trigger y source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @return select FlexTimer x hardware trigger y source select setting - */ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger); - -/*! - * @brief Sets the FlexTimer x external clock pin select setting. - * - * This function selects the source of FTMx external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select FTMx external clock pin select - * - 0: FTMx external clock driven by FTM CLKIN0 pin. - * - 1: FTMx external clock driven by FTM CLKIN1 pin. - */ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select); - -/*! - * @brief Gets the FlexTimer x external clock pin select setting. - * - * This function gets the FlexTimer x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select FlexTimer x external clock pin select setting - */ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the FlexTimer x channel y input capture source select setting. - * - * This function selects the FlexTimer x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y input capture source - */ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y input capture source select setting. - * - * This function gets the FlexTimer x channel y input capture - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y input capture source select setting - */ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Sets the FlexTimer x fault y select setting. - * - * This function sets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @param select FlexTimer x fault y select setting - * - 0: FlexTimer x fault y select 0. - * - 1: FlexTimer x fault y select 1. - */ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select); - -/*! - * @brief Gets the FlexTimer x fault y select setting. - * - * This function gets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @return select FlexTimer x fault y select setting - */ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault); - -/*! - * @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Fam ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Fam ID - */ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the FlexNVM size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size FlexNVM Size - */ -static inline uint32_t SIM_HAL_GetFlexnvmSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_NVMSIZE(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Gets the EEProm size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the EEProm size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size EEProm Size - */ -static inline uint32_t SIM_HAL_GetEepromSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_EESIZE(base); -} - -/*! - * @brief Gets the FlexNVM partition in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM partition in the Flash Configuration Register1 - * - * @param base Base address for current SIM instance. - * @return setting FlexNVM partition setting - */ -static inline uint32_t SIM_HAL_GetFlexnvmPartition(SIM_Type * base) -{ - return SIM_BRD_FCFG1_DEPART(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -/*! - * @brief Gets the program flash in the Flash Configuration Register 2. - * - * This function gets the program flash maximum block 0 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return status program flash status - */ -static inline uint32_t SIM_HAL_GetProgramFlashCmd(SIM_Type * base) -{ - return SIM_BRD_FCFG2_PFLSH(base); -} - -/*! - * @brief Gets the Swap program flash flag in the Flash Configuration Register 2. - * - * This function gets the Swap program flash flag in the Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return status - Swap program flash flag(Active or Inactive) - */ -static inline bool SIM_HAL_GetSwapProgramFlash(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG2_SWAPPFLSH(base); -} - - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ -/*! @}*/ - - -#endif /* __FSL_SIM_HAL_K40D10_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK50D10/fsl_sim_hal_MK50D10.c b/KSDK_1.2.0/platform/hal/src/sim/MK50D10/fsl_sim_hal_MK50D10.c deleted file mode 100755 index 46e1ed3..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK50D10/fsl_sim_hal_MK50D10.c +++ /dev/null @@ -1,750 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfDiv - * Description : Gets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} -#endif - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV3(outdiv3); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = SIM_BRD_CLKDIV1_OUTDIV3(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - SIM_BWR_SOPT4_FTM0FLT0(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0FLT1(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM0FLT2(base, select); - break; - default: - break; - } - break; - case 1: - SIM_BWR_SOPT4_FTM1FLT0(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2FLT0(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault) -{ - sim_ftm_flt_sel_t retValue = (sim_ftm_flt_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT0(base); - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT1(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT2(base); - break; - default: - break; - } - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM1FLT0(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM2FLT0(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK50D10/fsl_sim_hal_MK50D10.h b/KSDK_1.2.0/platform/hal/src/sim/MK50D10/fsl_sim_hal_MK50D10.h deleted file mode 100644 index e4a2d94..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK50D10/fsl_sim_hal_MK50D10.h +++ /dev/null @@ -1,1731 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_K50D10_H__) -#define __FSL_SIM_HAL_K50D10_H__ - - -/*! - * @addtogroup sim_hal_k50d10 - * @{ - */ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief WDOG clock source select */ -typedef enum _clock_wdog_src_t -{ - kClockWdogSrcLpoClk, /*!< LPO */ - kClockWdogSrcAltClk /*!< Alternative clock, for K50D10 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_wdog_src_k50d10_t; -#else -} clock_wdog_src_t; -#endif - -/*! @brief Debug trace clock source select */ -typedef enum _clock_trace_src_t -{ - kClockTraceSrcMcgoutClk, /*!< MCG out clock */ - kClockTraceSrcCoreClk /*!< core clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_trace_src_k50d10_t; -#else -} clock_trace_src_t; -#endif - -/*! @brief PORTx digital input filter clock source select */ -typedef enum _clock_port_filter_src_t -{ - kClockPortFilterSrcBusClk, /*!< Bus clock */ - kClockPortFilterSrcLpoClk /*!< LPO */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_port_filter_src_k50d10_t; -#else -} clock_port_filter_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG IRC clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_k50d10_t; -#else -} clock_lptmr_src_t; -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! @brief SIM timestamp clock source */ -typedef enum _clock_time_src -{ - kClockTimeSrcCoreSysClk, /*!< Core/system clock */ - kClockTimeSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTimeSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTimeSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_time_src_k50d10_t; -#else -} clock_time_src_t; -#endif -#endif // FSL_FEATURE_SOC_ENET_COUNT - -/*! @brief SIM RMII clock source */ -typedef enum _clock_rmii_src -{ - kClockRmiiSrcExtalClk, /*!< EXTAL Clock */ - kClockRmiiSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rmii_src_k50d10_t; -#else -} clock_rmii_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcPllFllSel, /*!< Clock divider USB FS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_k50d10_t; -#else -} clock_usbfs_src_t; -#endif -#endif // FSL_FEATURE_SOC_USB_COUNT - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*! @brief FLEXCAN clock source select */ -typedef enum _clock_flexcan_src_t -{ - kClockFlexcanSrcOsc0erClk, /*!< OSCERCLK */ - kClockFlexcanSrcBusClk /*!< Bus clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_flexcan_src_k50d10_t; -#else -} clock_flexcan_src_t; -#endif -#endif // FSL_FEATURE_SOC_FLEXCAN_COUNT - -/*! @brief SDHC clock source */ -typedef enum _clock_sdhc_src -{ - kClockSdhcSrcCoreSysClk, /*!< Core/system clock */ - kClockSdhcSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockSdhcSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockSdhcSrcExt /*!< External bypass clock (SDHC0_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sdhc_src_k50d10_t; -#else -} clock_sdhc_src_t; -#endif - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_k50d10_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief TSI Active Mode clock source */ -typedef enum _clock_tsi_active_mode_src -{ - kClockTsiActiveSrcBusClk, /*!< Bus clock */ - kClockTsiActiveSrcMcgIrClk, /*!< MCG IRC clock */ - kClockTsiActiveSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tsi_active_mode_src_k50d10_t; -#else -} clock_tsi_active_mode_src_t; -#endif - -/*! @brief TSI Low-power Mode clock source */ -typedef enum _clock_tsi_lp_mode_src -{ - kClockTsiLpSrcLpoClk, /*!< LPO clock */ - kClockTsiLpSrcEr32kClk /*!< ERCLK32K clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tsi_lp_mode_src_k50d10_t; -#else -} clock_tsi_lp_mode_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll = 0U, /*!< Fll clock */ - kClockPllFllSelPll = 1U, /*!< Pll0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_k50d10_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_k50d10_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlexbusClk = 0U, /*!< Flexbus clock */ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCG out clock */ - kClockClkoutSelRtc32kClk = 5U, /*!< RTC 32k clock */ - kClockClkoutSelOsc0erClk = 6U /*!< OSCERCLK0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_k50d10_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz /*!< 32kHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_k50d10_t; -#else -} clock_rtcout_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_k50d10_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_k50d10_t; -#else -} sim_usbvstby_mode_t; -#endif -#endif // FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_k50d10_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /*!< High speed comparator 0 output */ - kSimAdcTrgSelHighSpeedComp1 = 2U, /*!< High speed comparator 1 output */ - kSimAdcTrgSelHighSpeedComp2 = 3U, /*!< High speed comparator 2 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelPit2 = 6U, /*!< PIT trigger 2 */ - kSimAdcTrgSelPit3 = 7U, /*!< PIT trigger 3 */ - kSimAdcTrgSelFtm0 = 8U, /*!< FTM0 trigger */ - kSimAdcTrgSelFtm1 = 9U, /*!< FTM1 trigger */ - kSimAdcTrgSelFtm2 = 10U, /*!< FTM2 trigger */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_k50d10_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ - kSimUartRxsrcCmp1, /*!< CMP1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_k50d10_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcFtm1, /*!< UARTx_TX pin modulated with FTM1 channel 0 output */ - kSimUartTxsrcFtm2 /*!< UARTx_TX pin modulated with FTM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_k50d10_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM FlexTimer x trigger y select */ -typedef enum _sim_ftm_trg_src -{ - kSimFtmTrgSrc0, /*!< FlexTimer x trigger y select 0 */ - kSimFtmTrgSrc1 /*!< FlexTimer x trigger y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_trg_src_k50d10_t; -#else -} sim_ftm_trg_src_t; -#endif - -/*! @brief SIM FlexTimer external clock select */ -typedef enum _sim_ftm_clk_sel -{ - kSimFtmClkSel0, /*!< FTM CLKIN0 pin. */ - kSimFtmClkSel1 /*!< FTM CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_clk_sel_k50d10_t; -#else -} sim_ftm_clk_sel_t; -#endif - -/*! @brief SIM FlexTimer x channel y input capture source select */ -typedef enum _sim_ftm_ch_src -{ - kSimFtmChSrc0, /*!< FlexTimer x channel y input capture source 0. */ - kSimFtmChSrc1, /*!< FlexTimer x channel y input capture source 1. */ - kSimFtmChSrc2, /*!< FlexTimer x channel y input capture source 2. */ - kSimFtmChSrc3 /*!< FlexTimer x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_ch_src_k50d10_t; -#else -} sim_ftm_ch_src_t; -#endif - -/*! @brief SIM FlexTimer x Fault y select */ -typedef enum _sim_ftm_flt_sel -{ - kSimFtmFltSel0, /*!< FlexTimer x fault y select 0 */ - kSimFtmFltSel1 /*!< FlexTimer x fault y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_flt_sel_k50d10_t; -#else -} sim_ftm_flt_sel_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_k50d10_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1 /*!< CMP0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_k50d10_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM CMT/UART pad drive strength */ -typedef enum _sim_cmtuartpad_strengh -{ - kSimCmtuartSinglePad, /*!< Single-pad drive strength for CMT IRO or UART0_TXD */ - kSimCmtuartDualPad /*!< Dual-pad drive strength for CMT IRO or UART0_TXD */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_cmtuartpad_strengh_k50d10_t; -#else -} sim_cmtuartpad_strengh_t; -#endif - -/*! @brief SIM PTD7 pad drive strength */ -typedef enum _sim_ptd7pad_strengh -{ - kSimPtd7padSinglePad, /*!< Single-pad drive strength for PTD7 */ - kSimPtd7padDualPad /*!< Dual-pad drive strength for PTD7 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ptd7pad_strengh_k50d10_t; -#else -} sim_ptd7pad_strengh_t; -#endif - -/*! @brief SIM FlexBus security level */ -typedef enum _sim_flexbus_security_level -{ - kSimFbslLevel0, /*!< FlexBus security level 0. */ - kSimFbslLevel1, /*!< FlexBus security level 1. */ - kSimFbslLevel2, /*!< FlexBus security level 2. */ - kSimFbslLevel3, /*!< FlexBus security level 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_flexbus_security_level_k50d10_t; -#else -} sim_flexbus_security_level_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateUart4 = FSL_SIM_SCGC_BIT(1U, 10U), - kSimClockGateUart5 = FSL_SIM_SCGC_BIT(1U, 11U), -#if FSL_FEATURE_SOC_OPAMP_COUNT - kSimClockGateOpamp = FSL_SIM_SCGC_BIT(1U, 21U), -#endif -#if FSL_FEATURE_SOC_TRIAMP_COUNT - kSimClockGateTriamp = FSL_SIM_SCGC_BIT(1U, 24U), -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT - kSimClockGateEnet0 = FSL_SIM_SCGC_BIT(2U, 0U), -#endif - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(2U, 12U), - kSimClockGateDac1 = FSL_SIM_SCGC_BIT(2U, 13U), - -#if FSL_FEATURE_SOC_RNG_COUNT - kSimClockGateRnga0 = FSL_SIM_SCGC_BIT(3U, 0U), -#endif -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - kSimClockGateFlexcan1 = FSL_SIM_SCGC_BIT(3U, 4U), -#endif - kSimClockGateSpi2 = FSL_SIM_SCGC_BIT(3U, 12U), - kSimClockGateSdhc0 = FSL_SIM_SCGC_BIT(3U, 17U), - kSimClockGateFtm2 = FSL_SIM_SCGC_BIT(3U, 24U), - kSimClockGateAdc1 = FSL_SIM_SCGC_BIT(3U, 27U), -#if FSL_FEATURE_SOC_LCD_COUNT - kSimClockGateSlcd0 = FSL_SIM_SCGC_BIT(3U, 30U), -#endif - - kSimClockGateEwm0 = FSL_SIM_SCGC_BIT(4U, 1U), - kSimClockGateCmt0 = FSL_SIM_SCGC_BIT(4U, 2U), - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUart3 = FSL_SIM_SCGC_BIT(4U, 13U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), -#endif - kSimClockGateCmp = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateLlwu0 = FSL_SIM_SCGC_BIT(4U, 28U), - - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGateTsi0 = FSL_SIM_SCGC_BIT(5U, 5U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - kSimClockGateFlexcan0 = FSL_SIM_SCGC_BIT(6U, 4U), -#endif - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(6U, 12U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(6U, 13U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbdcd0 = FSL_SIM_SCGC_BIT(6U, 21U), -#endif - kSimClockGatePdb0 = FSL_SIM_SCGC_BIT(6U, 22U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateFtm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateFtm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - - kSimClockGateFlexbus0 = FSL_SIM_SCGC_BIT(7U, 0U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 1U), - kSimClockGateMpu0 = FSL_SIM_SCGC_BIT(7U, 2U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_k50d10_t; -#else -} sim_clock_gate_name_t; -#endif - -/*! @} */ -/******************************************************************************* - * API - ******************************************************************************/ - - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetSdhcSrc(SIM_Type * base, - uint32_t instance, - clock_sdhc_src_t setting) -{ - SIM_BWR_SOPT2_SDHCSRC(base, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_HAL_GetSdhcSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_sdhc_src_t)SIM_BRD_SOPT2_SDHCSRC(base); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTimeSrc(SIM_Type * base, - uint32_t instance, - clock_time_src_t setting) -{ - SIM_BWR_SOPT2_TIMESRC(base, setting); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_time_src_t CLOCK_HAL_GetTimeSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_time_src_t)SIM_BRD_SOPT2_TIMESRC(base); -} - -/*! - * @brief Set the Ethernet RMII interface clock source selection. - * - * This function sets the Ethernet RMII interface clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRmiiSrc(SIM_Type * base, - uint32_t instance, - clock_rmii_src_t setting) -{ - SIM_BWR_SOPT2_RMIISRC(base, setting); -} - -/*! - * @brief Get the Ethernet RMII interface clock source selection. - * - * This function gets the Ethernet RMII interface clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_rmii_src_t CLOCK_HAL_GetRmiiSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_rmii_src_t)SIM_BRD_SOPT2_RMIISRC(base); -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} -#endif - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set debug trace clock selection. - * - * This function sets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTraceClkSrc(SIM_Type * base, clock_trace_src_t setting) -{ - SIM_BWR_SOPT2_TRACECLKSEL(base, setting); -} - -/*! - * @brief Get debug trace clock selection. - * - * This function gets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_trace_src_t CLOCK_HAL_GetTraceClkSrc(SIM_Type * base) -{ - return (clock_trace_src_t)SIM_BRD_SOPT2_TRACECLKSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV2. - * - * This function sets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv2(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV2(base, setting); -} - -/*! - * @brief Get OUTDIV2. - * - * This function gets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv2(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV2(base); -} - -/*! - * @brief Set OUTDIV3. - * - * This function sets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv3(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV3(base, setting); -} - -/*! - * @brief Get OUTDIV3. - * - * This function gets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv3(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV3(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac); - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac); -#endif - -/*! - * @brief Gets RAM size. - * - * This function gets the RAM size. The field specifies the amount of system RAM - * available on the device. - * - * @param base Base address for current SIM instance. - * @return size RAM size on the device - */ -static inline uint32_t SIM_HAL_GetRamSize(SIM_Type * base) -{ - return SIM_BRD_SOPT1_RAMSIZE(base); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif - -/*! - * @brief Sets the PTD7 pad drive strength setting. - * - * This function controls the output drive strength of the PTD7 pin by selecting - * either one or two pads to drive it. - * - * @param base Base address for current SIM instance. - * @param setting PTD7 pad drive strength setting - * - 0: Single-pad drive strength for PTD7. - * - 1: Double pad drive strength for PTD7. - */ -static inline void SIM_HAL_SetPtd7PadDriveStrengthMode(SIM_Type * base, - sim_ptd7pad_strengh_t setting) -{ - SIM_BWR_SOPT2_PTD7PAD(base, setting); -} - -/*! - * @brief Gets the PTD7 pad drive strength setting. - * - * This function gets the PTD7 pad drive strength setting. - * - * @param base Base address for current SIM instance. - * @return setting PTD7 pad drive strength setting - */ -static inline sim_ptd7pad_strengh_t SIM_HAL_GetPtd7PadDriveStrengthMode(SIM_Type * base) -{ - return (sim_ptd7pad_strengh_t)SIM_BRD_SOPT2_PTD7PAD(base); -} - -/*! - * @brief Sets the FlexBus security level setting. - * - * This function sets the FlexBus security level setting. If the security is enabled, - * this field affects which CPU operations can access the off-chip via the FlexBus - * and DDR controller interfaces. This field has no effect if the security is not enabled. - * - * @param base Base address for current SIM instance. - * @param setting FlexBus security level setting - * - 00: All off-chip accesses (op code and data) via the FlexBus and - * DDR controller are disallowed. - * - 10: Off-chip op code accesses are disallowed. Data accesses are - * allowed. - * - 11: Off-chip op code accesses and data accesses are allowed. - */ -static inline void SIM_HAL_SetFlexbusSecurityLevelMode(SIM_Type * base, - sim_flexbus_security_level_t setting) -{ - SIM_BWR_SOPT2_FBSL(base, setting); -} - -/*! - * @brief Gets the FlexBus security level setting. - * - * This function gets the FlexBus security level setting. - * - * @param base Base address for current SIM instance. - * @return setting FlexBus security level setting - */ -static inline sim_flexbus_security_level_t SIM_HAL_GetFlexbusSecurityLevelMode(SIM_Type * base) -{ - return (sim_flexbus_security_level_t)SIM_BRD_SOPT2_FBSL(base); -} - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select); - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select); - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the FlexTimer x hardware trigger y source select setting. - * - * This function selects the source of FTMx hardware trigger y. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @param select FlexTimer x hardware trigger y - * - 0: Pre-trigger A selected for ADCx. - * - 1: Pre-trigger B selected for ADCx. - */ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select); - -/*! - * @brief Gets the FlexTimer x hardware trigger y source select setting. - * - * This function gets the FlexTimer x hardware trigger y source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @return select FlexTimer x hardware trigger y source select setting - */ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger); - -/*! - * @brief Sets the FlexTimer x external clock pin select setting. - * - * This function selects the source of FTMx external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select FTMx external clock pin select - * - 0: FTMx external clock driven by FTM CLKIN0 pin. - * - 1: FTMx external clock driven by FTM CLKIN1 pin. - */ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select); - -/*! - * @brief Gets the FlexTimer x external clock pin select setting. - * - * This function gets the FlexTimer x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select FlexTimer x external clock pin select setting - */ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the FlexTimer x channel y input capture source select setting. - * - * This function selects the FlexTimer x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y input capture source - */ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y input capture source select setting. - * - * This function gets the FlexTimer x channel y input capture - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y input capture source select setting - */ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Sets the FlexTimer x fault y select setting. - * - * This function sets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @param select FlexTimer x fault y select setting - * - 0: FlexTimer x fault y select 0. - * - 1: FlexTimer x fault y select 1. - */ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select); - -/*! - * @brief Gets the FlexTimer x fault y select setting. - * - * This function gets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @return select FlexTimer x fault y select setting - */ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault); - -/*! - * @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Fam ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Fam ID - */ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the FlexNVM size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size FlexNVM Size - */ -static inline uint32_t SIM_HAL_GetFlexnvmSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_NVMSIZE(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Gets the EEProm size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the EEProm size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size EEProm Size - */ -static inline uint32_t SIM_HAL_GetEepromSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_EESIZE(base); -} - -/*! - * @brief Gets the FlexNVM partition in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM partition in the Flash Configuration Register1 - * - * @param base Base address for current SIM instance. - * @return setting FlexNVM partition setting - */ -static inline uint32_t SIM_HAL_GetFlexnvmPartition(SIM_Type * base) -{ - return SIM_BRD_FCFG1_DEPART(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -/*! - * @brief Gets the program flash in the Flash Configuration Register 2. - * - * This function gets the program flash maximum block 0 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return status program flash status - */ -static inline uint32_t SIM_HAL_GetProgramFlashCmd(SIM_Type * base) -{ - return SIM_BRD_FCFG2_PFLSH(base); -} - -/*! - * @brief Gets the Swap program flash flag in the Flash Configuration Register 2. - * - * This function gets the Swap program flash flag in the Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return status - Swap program flash flag(Active or Inactive) - */ -static inline bool SIM_HAL_GetSwapProgramFlash(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG2_SWAPPFLSH(base); -} - - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ -/*! @}*/ - - -#endif /* __FSL_SIM_HAL_K50D10_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK51D10/fsl_sim_hal_MK51D10.c b/KSDK_1.2.0/platform/hal/src/sim/MK51D10/fsl_sim_hal_MK51D10.c deleted file mode 100755 index 46e1ed3..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK51D10/fsl_sim_hal_MK51D10.c +++ /dev/null @@ -1,750 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfDiv - * Description : Gets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} -#endif - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV3(outdiv3); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = SIM_BRD_CLKDIV1_OUTDIV3(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - SIM_BWR_SOPT4_FTM0FLT0(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0FLT1(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM0FLT2(base, select); - break; - default: - break; - } - break; - case 1: - SIM_BWR_SOPT4_FTM1FLT0(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2FLT0(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault) -{ - sim_ftm_flt_sel_t retValue = (sim_ftm_flt_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT0(base); - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT1(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT2(base); - break; - default: - break; - } - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM1FLT0(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM2FLT0(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK51D10/fsl_sim_hal_MK51D10.h b/KSDK_1.2.0/platform/hal/src/sim/MK51D10/fsl_sim_hal_MK51D10.h deleted file mode 100644 index aeba2c4..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK51D10/fsl_sim_hal_MK51D10.h +++ /dev/null @@ -1,1731 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_K51D10_H__) -#define __FSL_SIM_HAL_K51D10_H__ - - -/*! - * @addtogroup sim_hal_k51d10 - * @{ - */ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief WDOG clock source select */ -typedef enum _clock_wdog_src_t -{ - kClockWdogSrcLpoClk, /*!< LPO */ - kClockWdogSrcAltClk /*!< Alternative clock, for K51D10 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_wdog_src_k51d10_t; -#else -} clock_wdog_src_t; -#endif - -/*! @brief Debug trace clock source select */ -typedef enum _clock_trace_src_t -{ - kClockTraceSrcMcgoutClk, /*!< MCG out clock */ - kClockTraceSrcCoreClk /*!< core clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_trace_src_k51d10_t; -#else -} clock_trace_src_t; -#endif - -/*! @brief PORTx digital input filter clock source select */ -typedef enum _clock_port_filter_src_t -{ - kClockPortFilterSrcBusClk, /*!< Bus clock */ - kClockPortFilterSrcLpoClk /*!< LPO */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_port_filter_src_k51d10_t; -#else -} clock_port_filter_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG IRC clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_k51d10_t; -#else -} clock_lptmr_src_t; -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! @brief SIM timestamp clock source */ -typedef enum _clock_time_src -{ - kClockTimeSrcCoreSysClk, /*!< Core/system clock */ - kClockTimeSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTimeSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTimeSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_time_src_k51d10_t; -#else -} clock_time_src_t; -#endif -#endif // FSL_FEATURE_SOC_ENET_COUNT - -/*! @brief SIM RMII clock source */ -typedef enum _clock_rmii_src -{ - kClockRmiiSrcExtalClk, /*!< EXTAL Clock */ - kClockRmiiSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rmii_src_k51d10_t; -#else -} clock_rmii_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcPllFllSel, /*!< Clock divider USB FS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_k51d10_t; -#else -} clock_usbfs_src_t; -#endif -#endif // FSL_FEATURE_SOC_USB_COUNT - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*! @brief FLEXCAN clock source select */ -typedef enum _clock_flexcan_src_t -{ - kClockFlexcanSrcOsc0erClk, /*!< OSCERCLK */ - kClockFlexcanSrcBusClk /*!< Bus clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_flexcan_src_k51d10_t; -#else -} clock_flexcan_src_t; -#endif -#endif // FSL_FEATURE_SOC_FLEXCAN_COUNT - -/*! @brief SDHC clock source */ -typedef enum _clock_sdhc_src -{ - kClockSdhcSrcCoreSysClk, /*!< Core/system clock */ - kClockSdhcSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockSdhcSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockSdhcSrcExt /*!< External bypass clock (SDHC0_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sdhc_src_k51d10_t; -#else -} clock_sdhc_src_t; -#endif - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_k51d10_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief TSI Active Mode clock source */ -typedef enum _clock_tsi_active_mode_src -{ - kClockTsiActiveSrcBusClk, /*!< Bus clock */ - kClockTsiActiveSrcMcgIrClk, /*!< MCG IRC clock */ - kClockTsiActiveSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tsi_active_mode_src_k51d10_t; -#else -} clock_tsi_active_mode_src_t; -#endif - -/*! @brief TSI Low-power Mode clock source */ -typedef enum _clock_tsi_lp_mode_src -{ - kClockTsiLpSrcLpoClk, /*!< LPO clock */ - kClockTsiLpSrcEr32kClk /*!< ERCLK32K clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tsi_lp_mode_src_k51d10_t; -#else -} clock_tsi_lp_mode_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll = 0U, /*!< Fll clock */ - kClockPllFllSelPll = 1U, /*!< Pll0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_k51d10_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_k51d10_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlexbusClk = 0U, /*!< Flexbus clock */ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCG out clock */ - kClockClkoutSelRtc32kClk = 5U, /*!< RTC 32k clock */ - kClockClkoutSelOsc0erClk = 6U /*!< OSCERCLK0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_k51d10_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz /*!< 32kHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_k51d10_t; -#else -} clock_rtcout_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_k51d10_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_k51d10_t; -#else -} sim_usbvstby_mode_t; -#endif -#endif // FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_k51d10_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /*!< High speed comparator 0 output */ - kSimAdcTrgSelHighSpeedComp1 = 2U, /*!< High speed comparator 1 output */ - kSimAdcTrgSelHighSpeedComp2 = 3U, /*!< High speed comparator 2 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelPit2 = 6U, /*!< PIT trigger 2 */ - kSimAdcTrgSelPit3 = 7U, /*!< PIT trigger 3 */ - kSimAdcTrgSelFtm0 = 8U, /*!< FTM0 trigger */ - kSimAdcTrgSelFtm1 = 9U, /*!< FTM1 trigger */ - kSimAdcTrgSelFtm2 = 10U, /*!< FTM2 trigger */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_k51d10_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ - kSimUartRxsrcCmp1, /*!< CMP1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_k51d10_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcFtm1, /*!< UARTx_TX pin modulated with FTM1 channel 0 output */ - kSimUartTxsrcFtm2 /*!< UARTx_TX pin modulated with FTM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_k51d10_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM FlexTimer x trigger y select */ -typedef enum _sim_ftm_trg_src -{ - kSimFtmTrgSrc0, /*!< FlexTimer x trigger y select 0 */ - kSimFtmTrgSrc1 /*!< FlexTimer x trigger y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_trg_src_k51d10_t; -#else -} sim_ftm_trg_src_t; -#endif - -/*! @brief SIM FlexTimer external clock select */ -typedef enum _sim_ftm_clk_sel -{ - kSimFtmClkSel0, /*!< FTM CLKIN0 pin. */ - kSimFtmClkSel1 /*!< FTM CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_clk_sel_k51d10_t; -#else -} sim_ftm_clk_sel_t; -#endif - -/*! @brief SIM FlexTimer x channel y input capture source select */ -typedef enum _sim_ftm_ch_src -{ - kSimFtmChSrc0, /*!< FlexTimer x channel y input capture source 0. */ - kSimFtmChSrc1, /*!< FlexTimer x channel y input capture source 1. */ - kSimFtmChSrc2, /*!< FlexTimer x channel y input capture source 2. */ - kSimFtmChSrc3 /*!< FlexTimer x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_ch_src_k51d10_t; -#else -} sim_ftm_ch_src_t; -#endif - -/*! @brief SIM FlexTimer x Fault y select */ -typedef enum _sim_ftm_flt_sel -{ - kSimFtmFltSel0, /*!< FlexTimer x fault y select 0 */ - kSimFtmFltSel1 /*!< FlexTimer x fault y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_flt_sel_k51d10_t; -#else -} sim_ftm_flt_sel_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_k51d10_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1 /*!< CMP0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_k51d10_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM CMT/UART pad drive strength */ -typedef enum _sim_cmtuartpad_strengh -{ - kSimCmtuartSinglePad, /*!< Single-pad drive strength for CMT IRO or UART0_TXD */ - kSimCmtuartDualPad /*!< Dual-pad drive strength for CMT IRO or UART0_TXD */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_cmtuartpad_strengh_k51d10_t; -#else -} sim_cmtuartpad_strengh_t; -#endif - -/*! @brief SIM PTD7 pad drive strength */ -typedef enum _sim_ptd7pad_strengh -{ - kSimPtd7padSinglePad, /*!< Single-pad drive strength for PTD7 */ - kSimPtd7padDualPad /*!< Dual-pad drive strength for PTD7 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ptd7pad_strengh_k51d10_t; -#else -} sim_ptd7pad_strengh_t; -#endif - -/*! @brief SIM FlexBus security level */ -typedef enum _sim_flexbus_security_level -{ - kSimFbslLevel0, /*!< FlexBus security level 0. */ - kSimFbslLevel1, /*!< FlexBus security level 1. */ - kSimFbslLevel2, /*!< FlexBus security level 2. */ - kSimFbslLevel3, /*!< FlexBus security level 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_flexbus_security_level_k51d10_t; -#else -} sim_flexbus_security_level_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateUart4 = FSL_SIM_SCGC_BIT(1U, 10U), - kSimClockGateUart5 = FSL_SIM_SCGC_BIT(1U, 11U), -#if FSL_FEATURE_SOC_OPAMP_COUNT - kSimClockGateOpamp = FSL_SIM_SCGC_BIT(1U, 21U), -#endif -#if FSL_FEATURE_SOC_TRIAMP_COUNT - kSimClockGateTriamp = FSL_SIM_SCGC_BIT(1U, 24U), -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT - kSimClockGateEnet0 = FSL_SIM_SCGC_BIT(2U, 0U), -#endif - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(2U, 12U), - kSimClockGateDac1 = FSL_SIM_SCGC_BIT(2U, 13U), - -#if FSL_FEATURE_SOC_RNG_COUNT - kSimClockGateRnga0 = FSL_SIM_SCGC_BIT(3U, 0U), -#endif -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - kSimClockGateFlexcan1 = FSL_SIM_SCGC_BIT(3U, 4U), -#endif - kSimClockGateSpi2 = FSL_SIM_SCGC_BIT(3U, 12U), - kSimClockGateSdhc0 = FSL_SIM_SCGC_BIT(3U, 17U), - kSimClockGateFtm2 = FSL_SIM_SCGC_BIT(3U, 24U), - kSimClockGateAdc1 = FSL_SIM_SCGC_BIT(3U, 27U), -#if FSL_FEATURE_SOC_LCD_COUNT - kSimClockGateSlcd0 = FSL_SIM_SCGC_BIT(3U, 30U), -#endif - - kSimClockGateEwm0 = FSL_SIM_SCGC_BIT(4U, 1U), - kSimClockGateCmt0 = FSL_SIM_SCGC_BIT(4U, 2U), - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUart3 = FSL_SIM_SCGC_BIT(4U, 13U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), -#endif - kSimClockGateCmp = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateLlwu0 = FSL_SIM_SCGC_BIT(4U, 28U), - - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGateTsi0 = FSL_SIM_SCGC_BIT(5U, 5U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - kSimClockGateFlexcan0 = FSL_SIM_SCGC_BIT(6U, 4U), -#endif - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(6U, 12U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(6U, 13U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbdcd0 = FSL_SIM_SCGC_BIT(6U, 21U), -#endif - kSimClockGatePdb0 = FSL_SIM_SCGC_BIT(6U, 22U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateFtm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateFtm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - - kSimClockGateFlexbus0 = FSL_SIM_SCGC_BIT(7U, 0U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 1U), - kSimClockGateMpu0 = FSL_SIM_SCGC_BIT(7U, 2U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_k51d10_t; -#else -} sim_clock_gate_name_t; -#endif - -/*! @} */ -/******************************************************************************* - * API - ******************************************************************************/ - - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetSdhcSrc(SIM_Type * base, - uint32_t instance, - clock_sdhc_src_t setting) -{ - SIM_BWR_SOPT2_SDHCSRC(base, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_HAL_GetSdhcSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_sdhc_src_t)SIM_BRD_SOPT2_SDHCSRC(base); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTimeSrc(SIM_Type * base, - uint32_t instance, - clock_time_src_t setting) -{ - SIM_BWR_SOPT2_TIMESRC(base, setting); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_time_src_t CLOCK_HAL_GetTimeSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_time_src_t)SIM_BRD_SOPT2_TIMESRC(base); -} - -/*! - * @brief Set the Ethernet RMII interface clock source selection. - * - * This function sets the Ethernet RMII interface clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRmiiSrc(SIM_Type * base, - uint32_t instance, - clock_rmii_src_t setting) -{ - SIM_BWR_SOPT2_RMIISRC(base, setting); -} - -/*! - * @brief Get the Ethernet RMII interface clock source selection. - * - * This function gets the Ethernet RMII interface clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_rmii_src_t CLOCK_HAL_GetRmiiSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_rmii_src_t)SIM_BRD_SOPT2_RMIISRC(base); -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} -#endif - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set debug trace clock selection. - * - * This function sets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTraceClkSrc(SIM_Type * base, clock_trace_src_t setting) -{ - SIM_BWR_SOPT2_TRACECLKSEL(base, setting); -} - -/*! - * @brief Get debug trace clock selection. - * - * This function gets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_trace_src_t CLOCK_HAL_GetTraceClkSrc(SIM_Type * base) -{ - return (clock_trace_src_t)SIM_BRD_SOPT2_TRACECLKSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV2. - * - * This function sets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv2(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV2(base, setting); -} - -/*! - * @brief Get OUTDIV2. - * - * This function gets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv2(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV2(base); -} - -/*! - * @brief Set OUTDIV3. - * - * This function sets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv3(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV3(base, setting); -} - -/*! - * @brief Get OUTDIV3. - * - * This function gets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv3(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV3(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac); - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac); -#endif - -/*! - * @brief Gets RAM size. - * - * This function gets the RAM size. The field specifies the amount of system RAM - * available on the device. - * - * @param base Base address for current SIM instance. - * @return size RAM size on the device - */ -static inline uint32_t SIM_HAL_GetRamSize(SIM_Type * base) -{ - return SIM_BRD_SOPT1_RAMSIZE(base); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif - -/*! - * @brief Sets the PTD7 pad drive strength setting. - * - * This function controls the output drive strength of the PTD7 pin by selecting - * either one or two pads to drive it. - * - * @param base Base address for current SIM instance. - * @param setting PTD7 pad drive strength setting - * - 0: Single-pad drive strength for PTD7. - * - 1: Double pad drive strength for PTD7. - */ -static inline void SIM_HAL_SetPtd7PadDriveStrengthMode(SIM_Type * base, - sim_ptd7pad_strengh_t setting) -{ - SIM_BWR_SOPT2_PTD7PAD(base, setting); -} - -/*! - * @brief Gets the PTD7 pad drive strength setting. - * - * This function gets the PTD7 pad drive strength setting. - * - * @param base Base address for current SIM instance. - * @return setting PTD7 pad drive strength setting - */ -static inline sim_ptd7pad_strengh_t SIM_HAL_GetPtd7PadDriveStrengthMode(SIM_Type * base) -{ - return (sim_ptd7pad_strengh_t)SIM_BRD_SOPT2_PTD7PAD(base); -} - -/*! - * @brief Sets the FlexBus security level setting. - * - * This function sets the FlexBus security level setting. If the security is enabled, - * this field affects which CPU operations can access the off-chip via the FlexBus - * and DDR controller interfaces. This field has no effect if the security is not enabled. - * - * @param base Base address for current SIM instance. - * @param setting FlexBus security level setting - * - 00: All off-chip accesses (op code and data) via the FlexBus and - * DDR controller are disallowed. - * - 10: Off-chip op code accesses are disallowed. Data accesses are - * allowed. - * - 11: Off-chip op code accesses and data accesses are allowed. - */ -static inline void SIM_HAL_SetFlexbusSecurityLevelMode(SIM_Type * base, - sim_flexbus_security_level_t setting) -{ - SIM_BWR_SOPT2_FBSL(base, setting); -} - -/*! - * @brief Gets the FlexBus security level setting. - * - * This function gets the FlexBus security level setting. - * - * @param base Base address for current SIM instance. - * @return setting FlexBus security level setting - */ -static inline sim_flexbus_security_level_t SIM_HAL_GetFlexbusSecurityLevelMode(SIM_Type * base) -{ - return (sim_flexbus_security_level_t)SIM_BRD_SOPT2_FBSL(base); -} - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select); - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select); - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the FlexTimer x hardware trigger y source select setting. - * - * This function selects the source of FTMx hardware trigger y. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @param select FlexTimer x hardware trigger y - * - 0: Pre-trigger A selected for ADCx. - * - 1: Pre-trigger B selected for ADCx. - */ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select); - -/*! - * @brief Gets the FlexTimer x hardware trigger y source select setting. - * - * This function gets the FlexTimer x hardware trigger y source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @return select FlexTimer x hardware trigger y source select setting - */ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger); - -/*! - * @brief Sets the FlexTimer x external clock pin select setting. - * - * This function selects the source of FTMx external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select FTMx external clock pin select - * - 0: FTMx external clock driven by FTM CLKIN0 pin. - * - 1: FTMx external clock driven by FTM CLKIN1 pin. - */ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select); - -/*! - * @brief Gets the FlexTimer x external clock pin select setting. - * - * This function gets the FlexTimer x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select FlexTimer x external clock pin select setting - */ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the FlexTimer x channel y input capture source select setting. - * - * This function selects the FlexTimer x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y input capture source - */ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y input capture source select setting. - * - * This function gets the FlexTimer x channel y input capture - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y input capture source select setting - */ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Sets the FlexTimer x fault y select setting. - * - * This function sets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @param select FlexTimer x fault y select setting - * - 0: FlexTimer x fault y select 0. - * - 1: FlexTimer x fault y select 1. - */ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select); - -/*! - * @brief Gets the FlexTimer x fault y select setting. - * - * This function gets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @return select FlexTimer x fault y select setting - */ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault); - -/*! - * @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Fam ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Fam ID - */ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the FlexNVM size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size FlexNVM Size - */ -static inline uint32_t SIM_HAL_GetFlexnvmSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_NVMSIZE(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Gets the EEProm size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the EEProm size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size EEProm Size - */ -static inline uint32_t SIM_HAL_GetEepromSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_EESIZE(base); -} - -/*! - * @brief Gets the FlexNVM partition in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM partition in the Flash Configuration Register1 - * - * @param base Base address for current SIM instance. - * @return setting FlexNVM partition setting - */ -static inline uint32_t SIM_HAL_GetFlexnvmPartition(SIM_Type * base) -{ - return SIM_BRD_FCFG1_DEPART(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -/*! - * @brief Gets the program flash in the Flash Configuration Register 2. - * - * This function gets the program flash maximum block 0 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return status program flash status - */ -static inline uint32_t SIM_HAL_GetProgramFlashCmd(SIM_Type * base) -{ - return SIM_BRD_FCFG2_PFLSH(base); -} - -/*! - * @brief Gets the Swap program flash flag in the Flash Configuration Register 2. - * - * This function gets the Swap program flash flag in the Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return status - Swap program flash flag(Active or Inactive) - */ -static inline bool SIM_HAL_GetSwapProgramFlash(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG2_SWAPPFLSH(base); -} - - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ -/*! @}*/ - - -#endif /* __FSL_SIM_HAL_K51D10_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK52D10/fsl_sim_hal_MK52D10.c b/KSDK_1.2.0/platform/hal/src/sim/MK52D10/fsl_sim_hal_MK52D10.c deleted file mode 100755 index 46e1ed3..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK52D10/fsl_sim_hal_MK52D10.c +++ /dev/null @@ -1,750 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfDiv - * Description : Gets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} -#endif - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV3(outdiv3); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = SIM_BRD_CLKDIV1_OUTDIV3(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - SIM_BWR_SOPT4_FTM0FLT0(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0FLT1(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM0FLT2(base, select); - break; - default: - break; - } - break; - case 1: - SIM_BWR_SOPT4_FTM1FLT0(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2FLT0(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault) -{ - sim_ftm_flt_sel_t retValue = (sim_ftm_flt_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT0(base); - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT1(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT2(base); - break; - default: - break; - } - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM1FLT0(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM2FLT0(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK52D10/fsl_sim_hal_MK52D10.h b/KSDK_1.2.0/platform/hal/src/sim/MK52D10/fsl_sim_hal_MK52D10.h deleted file mode 100644 index ea7c8eb..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK52D10/fsl_sim_hal_MK52D10.h +++ /dev/null @@ -1,1731 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_K52D10_H__) -#define __FSL_SIM_HAL_K52D10_H__ - - -/*! - * @addtogroup sim_hal_k52d10 - * @{ - */ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief WDOG clock source select */ -typedef enum _clock_wdog_src_t -{ - kClockWdogSrcLpoClk, /*!< LPO */ - kClockWdogSrcAltClk /*!< Alternative clock, for K52D10 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_wdog_src_k52d10_t; -#else -} clock_wdog_src_t; -#endif - -/*! @brief Debug trace clock source select */ -typedef enum _clock_trace_src_t -{ - kClockTraceSrcMcgoutClk, /*!< MCG out clock */ - kClockTraceSrcCoreClk /*!< core clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_trace_src_k52d10_t; -#else -} clock_trace_src_t; -#endif - -/*! @brief PORTx digital input filter clock source select */ -typedef enum _clock_port_filter_src_t -{ - kClockPortFilterSrcBusClk, /*!< Bus clock */ - kClockPortFilterSrcLpoClk /*!< LPO */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_port_filter_src_k52d10_t; -#else -} clock_port_filter_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG IRC clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_k52d10_t; -#else -} clock_lptmr_src_t; -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! @brief SIM timestamp clock source */ -typedef enum _clock_time_src -{ - kClockTimeSrcCoreSysClk, /*!< Core/system clock */ - kClockTimeSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTimeSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTimeSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_time_src_k52d10_t; -#else -} clock_time_src_t; -#endif -#endif // FSL_FEATURE_SOC_ENET_COUNT - -/*! @brief SIM RMII clock source */ -typedef enum _clock_rmii_src -{ - kClockRmiiSrcExtalClk, /*!< EXTAL Clock */ - kClockRmiiSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rmii_src_k52d10_t; -#else -} clock_rmii_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcPllFllSel, /*!< Clock divider USB FS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_k52d10_t; -#else -} clock_usbfs_src_t; -#endif -#endif // FSL_FEATURE_SOC_USB_COUNT - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*! @brief FLEXCAN clock source select */ -typedef enum _clock_flexcan_src_t -{ - kClockFlexcanSrcOsc0erClk, /*!< OSCERCLK */ - kClockFlexcanSrcBusClk /*!< Bus clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_flexcan_src_k52d10_t; -#else -} clock_flexcan_src_t; -#endif -#endif // FSL_FEATURE_SOC_FLEXCAN_COUNT - -/*! @brief SDHC clock source */ -typedef enum _clock_sdhc_src -{ - kClockSdhcSrcCoreSysClk, /*!< Core/system clock */ - kClockSdhcSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockSdhcSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockSdhcSrcExt /*!< External bypass clock (SDHC0_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sdhc_src_k52d10_t; -#else -} clock_sdhc_src_t; -#endif - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_k52d10_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief TSI Active Mode clock source */ -typedef enum _clock_tsi_active_mode_src -{ - kClockTsiActiveSrcBusClk, /*!< Bus clock */ - kClockTsiActiveSrcMcgIrClk, /*!< MCG IRC clock */ - kClockTsiActiveSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tsi_active_mode_src_k52d10_t; -#else -} clock_tsi_active_mode_src_t; -#endif - -/*! @brief TSI Low-power Mode clock source */ -typedef enum _clock_tsi_lp_mode_src -{ - kClockTsiLpSrcLpoClk, /*!< LPO clock */ - kClockTsiLpSrcEr32kClk /*!< ERCLK32K clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tsi_lp_mode_src_k52d10_t; -#else -} clock_tsi_lp_mode_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll = 0U, /*!< Fll clock */ - kClockPllFllSelPll = 1U, /*!< Pll0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_k52d10_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_k52d10_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlexbusClk = 0U, /*!< Flexbus clock */ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCG out clock */ - kClockClkoutSelRtc32kClk = 5U, /*!< RTC 32k clock */ - kClockClkoutSelOsc0erClk = 6U /*!< OSCERCLK0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_k52d10_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz /*!< 32kHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_k52d10_t; -#else -} clock_rtcout_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_k52d10_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_k52d10_t; -#else -} sim_usbvstby_mode_t; -#endif -#endif // FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_k52d10_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /*!< High speed comparator 0 output */ - kSimAdcTrgSelHighSpeedComp1 = 2U, /*!< High speed comparator 1 output */ - kSimAdcTrgSelHighSpeedComp2 = 3U, /*!< High speed comparator 2 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelPit2 = 6U, /*!< PIT trigger 2 */ - kSimAdcTrgSelPit3 = 7U, /*!< PIT trigger 3 */ - kSimAdcTrgSelFtm0 = 8U, /*!< FTM0 trigger */ - kSimAdcTrgSelFtm1 = 9U, /*!< FTM1 trigger */ - kSimAdcTrgSelFtm2 = 10U, /*!< FTM2 trigger */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_k52d10_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ - kSimUartRxsrcCmp1, /*!< CMP1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_k52d10_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcFtm1, /*!< UARTx_TX pin modulated with FTM1 channel 0 output */ - kSimUartTxsrcFtm2 /*!< UARTx_TX pin modulated with FTM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_k52d10_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM FlexTimer x trigger y select */ -typedef enum _sim_ftm_trg_src -{ - kSimFtmTrgSrc0, /*!< FlexTimer x trigger y select 0 */ - kSimFtmTrgSrc1 /*!< FlexTimer x trigger y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_trg_src_k52d10_t; -#else -} sim_ftm_trg_src_t; -#endif - -/*! @brief SIM FlexTimer external clock select */ -typedef enum _sim_ftm_clk_sel -{ - kSimFtmClkSel0, /*!< FTM CLKIN0 pin. */ - kSimFtmClkSel1 /*!< FTM CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_clk_sel_k52d10_t; -#else -} sim_ftm_clk_sel_t; -#endif - -/*! @brief SIM FlexTimer x channel y input capture source select */ -typedef enum _sim_ftm_ch_src -{ - kSimFtmChSrc0, /*!< FlexTimer x channel y input capture source 0. */ - kSimFtmChSrc1, /*!< FlexTimer x channel y input capture source 1. */ - kSimFtmChSrc2, /*!< FlexTimer x channel y input capture source 2. */ - kSimFtmChSrc3 /*!< FlexTimer x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_ch_src_k52d10_t; -#else -} sim_ftm_ch_src_t; -#endif - -/*! @brief SIM FlexTimer x Fault y select */ -typedef enum _sim_ftm_flt_sel -{ - kSimFtmFltSel0, /*!< FlexTimer x fault y select 0 */ - kSimFtmFltSel1 /*!< FlexTimer x fault y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_flt_sel_k52d10_t; -#else -} sim_ftm_flt_sel_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_k52d10_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1 /*!< CMP0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_k52d10_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM CMT/UART pad drive strength */ -typedef enum _sim_cmtuartpad_strengh -{ - kSimCmtuartSinglePad, /*!< Single-pad drive strength for CMT IRO or UART0_TXD */ - kSimCmtuartDualPad /*!< Dual-pad drive strength for CMT IRO or UART0_TXD */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_cmtuartpad_strengh_k52d10_t; -#else -} sim_cmtuartpad_strengh_t; -#endif - -/*! @brief SIM PTD7 pad drive strength */ -typedef enum _sim_ptd7pad_strengh -{ - kSimPtd7padSinglePad, /*!< Single-pad drive strength for PTD7 */ - kSimPtd7padDualPad /*!< Dual-pad drive strength for PTD7 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ptd7pad_strengh_k52d10_t; -#else -} sim_ptd7pad_strengh_t; -#endif - -/*! @brief SIM FlexBus security level */ -typedef enum _sim_flexbus_security_level -{ - kSimFbslLevel0, /*!< FlexBus security level 0. */ - kSimFbslLevel1, /*!< FlexBus security level 1. */ - kSimFbslLevel2, /*!< FlexBus security level 2. */ - kSimFbslLevel3, /*!< FlexBus security level 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_flexbus_security_level_k52d10_t; -#else -} sim_flexbus_security_level_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateUart4 = FSL_SIM_SCGC_BIT(1U, 10U), - kSimClockGateUart5 = FSL_SIM_SCGC_BIT(1U, 11U), -#if FSL_FEATURE_SOC_OPAMP_COUNT - kSimClockGateOpamp = FSL_SIM_SCGC_BIT(1U, 21U), -#endif -#if FSL_FEATURE_SOC_TRIAMP_COUNT - kSimClockGateTriamp = FSL_SIM_SCGC_BIT(1U, 24U), -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT - kSimClockGateEnet0 = FSL_SIM_SCGC_BIT(2U, 0U), -#endif - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(2U, 12U), - kSimClockGateDac1 = FSL_SIM_SCGC_BIT(2U, 13U), - -#if FSL_FEATURE_SOC_RNG_COUNT - kSimClockGateRnga0 = FSL_SIM_SCGC_BIT(3U, 0U), -#endif -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - kSimClockGateFlexcan1 = FSL_SIM_SCGC_BIT(3U, 4U), -#endif - kSimClockGateSpi2 = FSL_SIM_SCGC_BIT(3U, 12U), - kSimClockGateSdhc0 = FSL_SIM_SCGC_BIT(3U, 17U), - kSimClockGateFtm2 = FSL_SIM_SCGC_BIT(3U, 24U), - kSimClockGateAdc1 = FSL_SIM_SCGC_BIT(3U, 27U), -#if FSL_FEATURE_SOC_LCD_COUNT - kSimClockGateSlcd0 = FSL_SIM_SCGC_BIT(3U, 30U), -#endif - - kSimClockGateEwm0 = FSL_SIM_SCGC_BIT(4U, 1U), - kSimClockGateCmt0 = FSL_SIM_SCGC_BIT(4U, 2U), - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUart3 = FSL_SIM_SCGC_BIT(4U, 13U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), -#endif - kSimClockGateCmp = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateLlwu0 = FSL_SIM_SCGC_BIT(4U, 28U), - - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGateTsi0 = FSL_SIM_SCGC_BIT(5U, 5U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - kSimClockGateFlexcan0 = FSL_SIM_SCGC_BIT(6U, 4U), -#endif - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(6U, 12U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(6U, 13U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbdcd0 = FSL_SIM_SCGC_BIT(6U, 21U), -#endif - kSimClockGatePdb0 = FSL_SIM_SCGC_BIT(6U, 22U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateFtm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateFtm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - - kSimClockGateFlexbus0 = FSL_SIM_SCGC_BIT(7U, 0U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 1U), - kSimClockGateMpu0 = FSL_SIM_SCGC_BIT(7U, 2U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_k52d10_t; -#else -} sim_clock_gate_name_t; -#endif - -/*! @} */ -/******************************************************************************* - * API - ******************************************************************************/ - - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetSdhcSrc(SIM_Type * base, - uint32_t instance, - clock_sdhc_src_t setting) -{ - SIM_BWR_SOPT2_SDHCSRC(base, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_HAL_GetSdhcSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_sdhc_src_t)SIM_BRD_SOPT2_SDHCSRC(base); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTimeSrc(SIM_Type * base, - uint32_t instance, - clock_time_src_t setting) -{ - SIM_BWR_SOPT2_TIMESRC(base, setting); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_time_src_t CLOCK_HAL_GetTimeSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_time_src_t)SIM_BRD_SOPT2_TIMESRC(base); -} - -/*! - * @brief Set the Ethernet RMII interface clock source selection. - * - * This function sets the Ethernet RMII interface clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRmiiSrc(SIM_Type * base, - uint32_t instance, - clock_rmii_src_t setting) -{ - SIM_BWR_SOPT2_RMIISRC(base, setting); -} - -/*! - * @brief Get the Ethernet RMII interface clock source selection. - * - * This function gets the Ethernet RMII interface clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_rmii_src_t CLOCK_HAL_GetRmiiSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_rmii_src_t)SIM_BRD_SOPT2_RMIISRC(base); -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} -#endif - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set debug trace clock selection. - * - * This function sets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTraceClkSrc(SIM_Type * base, clock_trace_src_t setting) -{ - SIM_BWR_SOPT2_TRACECLKSEL(base, setting); -} - -/*! - * @brief Get debug trace clock selection. - * - * This function gets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_trace_src_t CLOCK_HAL_GetTraceClkSrc(SIM_Type * base) -{ - return (clock_trace_src_t)SIM_BRD_SOPT2_TRACECLKSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV2. - * - * This function sets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv2(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV2(base, setting); -} - -/*! - * @brief Get OUTDIV2. - * - * This function gets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv2(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV2(base); -} - -/*! - * @brief Set OUTDIV3. - * - * This function sets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv3(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV3(base, setting); -} - -/*! - * @brief Get OUTDIV3. - * - * This function gets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv3(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV3(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac); - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac); -#endif - -/*! - * @brief Gets RAM size. - * - * This function gets the RAM size. The field specifies the amount of system RAM - * available on the device. - * - * @param base Base address for current SIM instance. - * @return size RAM size on the device - */ -static inline uint32_t SIM_HAL_GetRamSize(SIM_Type * base) -{ - return SIM_BRD_SOPT1_RAMSIZE(base); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif - -/*! - * @brief Sets the PTD7 pad drive strength setting. - * - * This function controls the output drive strength of the PTD7 pin by selecting - * either one or two pads to drive it. - * - * @param base Base address for current SIM instance. - * @param setting PTD7 pad drive strength setting - * - 0: Single-pad drive strength for PTD7. - * - 1: Double pad drive strength for PTD7. - */ -static inline void SIM_HAL_SetPtd7PadDriveStrengthMode(SIM_Type * base, - sim_ptd7pad_strengh_t setting) -{ - SIM_BWR_SOPT2_PTD7PAD(base, setting); -} - -/*! - * @brief Gets the PTD7 pad drive strength setting. - * - * This function gets the PTD7 pad drive strength setting. - * - * @param base Base address for current SIM instance. - * @return setting PTD7 pad drive strength setting - */ -static inline sim_ptd7pad_strengh_t SIM_HAL_GetPtd7PadDriveStrengthMode(SIM_Type * base) -{ - return (sim_ptd7pad_strengh_t)SIM_BRD_SOPT2_PTD7PAD(base); -} - -/*! - * @brief Sets the FlexBus security level setting. - * - * This function sets the FlexBus security level setting. If the security is enabled, - * this field affects which CPU operations can access the off-chip via the FlexBus - * and DDR controller interfaces. This field has no effect if the security is not enabled. - * - * @param base Base address for current SIM instance. - * @param setting FlexBus security level setting - * - 00: All off-chip accesses (op code and data) via the FlexBus and - * DDR controller are disallowed. - * - 10: Off-chip op code accesses are disallowed. Data accesses are - * allowed. - * - 11: Off-chip op code accesses and data accesses are allowed. - */ -static inline void SIM_HAL_SetFlexbusSecurityLevelMode(SIM_Type * base, - sim_flexbus_security_level_t setting) -{ - SIM_BWR_SOPT2_FBSL(base, setting); -} - -/*! - * @brief Gets the FlexBus security level setting. - * - * This function gets the FlexBus security level setting. - * - * @param base Base address for current SIM instance. - * @return setting FlexBus security level setting - */ -static inline sim_flexbus_security_level_t SIM_HAL_GetFlexbusSecurityLevelMode(SIM_Type * base) -{ - return (sim_flexbus_security_level_t)SIM_BRD_SOPT2_FBSL(base); -} - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select); - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select); - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the FlexTimer x hardware trigger y source select setting. - * - * This function selects the source of FTMx hardware trigger y. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @param select FlexTimer x hardware trigger y - * - 0: Pre-trigger A selected for ADCx. - * - 1: Pre-trigger B selected for ADCx. - */ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select); - -/*! - * @brief Gets the FlexTimer x hardware trigger y source select setting. - * - * This function gets the FlexTimer x hardware trigger y source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @return select FlexTimer x hardware trigger y source select setting - */ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger); - -/*! - * @brief Sets the FlexTimer x external clock pin select setting. - * - * This function selects the source of FTMx external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select FTMx external clock pin select - * - 0: FTMx external clock driven by FTM CLKIN0 pin. - * - 1: FTMx external clock driven by FTM CLKIN1 pin. - */ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select); - -/*! - * @brief Gets the FlexTimer x external clock pin select setting. - * - * This function gets the FlexTimer x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select FlexTimer x external clock pin select setting - */ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the FlexTimer x channel y input capture source select setting. - * - * This function selects the FlexTimer x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y input capture source - */ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y input capture source select setting. - * - * This function gets the FlexTimer x channel y input capture - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y input capture source select setting - */ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Sets the FlexTimer x fault y select setting. - * - * This function sets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @param select FlexTimer x fault y select setting - * - 0: FlexTimer x fault y select 0. - * - 1: FlexTimer x fault y select 1. - */ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select); - -/*! - * @brief Gets the FlexTimer x fault y select setting. - * - * This function gets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @return select FlexTimer x fault y select setting - */ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault); - -/*! - * @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Fam ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Fam ID - */ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the FlexNVM size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size FlexNVM Size - */ -static inline uint32_t SIM_HAL_GetFlexnvmSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_NVMSIZE(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Gets the EEProm size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the EEProm size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size EEProm Size - */ -static inline uint32_t SIM_HAL_GetEepromSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_EESIZE(base); -} - -/*! - * @brief Gets the FlexNVM partition in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM partition in the Flash Configuration Register1 - * - * @param base Base address for current SIM instance. - * @return setting FlexNVM partition setting - */ -static inline uint32_t SIM_HAL_GetFlexnvmPartition(SIM_Type * base) -{ - return SIM_BRD_FCFG1_DEPART(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -/*! - * @brief Gets the program flash in the Flash Configuration Register 2. - * - * This function gets the program flash maximum block 0 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return status program flash status - */ -static inline uint32_t SIM_HAL_GetProgramFlashCmd(SIM_Type * base) -{ - return SIM_BRD_FCFG2_PFLSH(base); -} - -/*! - * @brief Gets the Swap program flash flag in the Flash Configuration Register 2. - * - * This function gets the Swap program flash flag in the Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return status - Swap program flash flag(Active or Inactive) - */ -static inline bool SIM_HAL_GetSwapProgramFlash(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG2_SWAPPFLSH(base); -} - - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ -/*! @}*/ - - -#endif /* __FSL_SIM_HAL_K52D10_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK53D10/fsl_sim_hal_MK53D10.c b/KSDK_1.2.0/platform/hal/src/sim/MK53D10/fsl_sim_hal_MK53D10.c deleted file mode 100755 index 46e1ed3..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK53D10/fsl_sim_hal_MK53D10.c +++ /dev/null @@ -1,750 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfDiv - * Description : Gets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} -#endif - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV3(outdiv3); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = SIM_BRD_CLKDIV1_OUTDIV3(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - SIM_BWR_SOPT4_FTM0FLT0(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0FLT1(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM0FLT2(base, select); - break; - default: - break; - } - break; - case 1: - SIM_BWR_SOPT4_FTM1FLT0(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2FLT0(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault) -{ - sim_ftm_flt_sel_t retValue = (sim_ftm_flt_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT0(base); - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT1(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT2(base); - break; - default: - break; - } - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM1FLT0(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM2FLT0(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK53D10/fsl_sim_hal_MK53D10.h b/KSDK_1.2.0/platform/hal/src/sim/MK53D10/fsl_sim_hal_MK53D10.h deleted file mode 100644 index c33375f..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK53D10/fsl_sim_hal_MK53D10.h +++ /dev/null @@ -1,1731 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_K53D10_H__) -#define __FSL_SIM_HAL_K53D10_H__ - - -/*! - * @addtogroup sim_hal_k53d10 - * @{ - */ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief WDOG clock source select */ -typedef enum _clock_wdog_src_t -{ - kClockWdogSrcLpoClk, /*!< LPO */ - kClockWdogSrcAltClk /*!< Alternative clock, for K53D10 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_wdog_src_k53d10_t; -#else -} clock_wdog_src_t; -#endif - -/*! @brief Debug trace clock source select */ -typedef enum _clock_trace_src_t -{ - kClockTraceSrcMcgoutClk, /*!< MCG out clock */ - kClockTraceSrcCoreClk /*!< core clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_trace_src_k53d10_t; -#else -} clock_trace_src_t; -#endif - -/*! @brief PORTx digital input filter clock source select */ -typedef enum _clock_port_filter_src_t -{ - kClockPortFilterSrcBusClk, /*!< Bus clock */ - kClockPortFilterSrcLpoClk /*!< LPO */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_port_filter_src_k53d10_t; -#else -} clock_port_filter_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG IRC clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_k53d10_t; -#else -} clock_lptmr_src_t; -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! @brief SIM timestamp clock source */ -typedef enum _clock_time_src -{ - kClockTimeSrcCoreSysClk, /*!< Core/system clock */ - kClockTimeSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTimeSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTimeSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_time_src_k53d10_t; -#else -} clock_time_src_t; -#endif -#endif // FSL_FEATURE_SOC_ENET_COUNT - -/*! @brief SIM RMII clock source */ -typedef enum _clock_rmii_src -{ - kClockRmiiSrcExtalClk, /*!< EXTAL Clock */ - kClockRmiiSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rmii_src_k53d10_t; -#else -} clock_rmii_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcPllFllSel, /*!< Clock divider USB FS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_k53d10_t; -#else -} clock_usbfs_src_t; -#endif -#endif // FSL_FEATURE_SOC_USB_COUNT - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*! @brief FLEXCAN clock source select */ -typedef enum _clock_flexcan_src_t -{ - kClockFlexcanSrcOsc0erClk, /*!< OSCERCLK */ - kClockFlexcanSrcBusClk /*!< Bus clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_flexcan_src_k53d10_t; -#else -} clock_flexcan_src_t; -#endif -#endif // FSL_FEATURE_SOC_FLEXCAN_COUNT - -/*! @brief SDHC clock source */ -typedef enum _clock_sdhc_src -{ - kClockSdhcSrcCoreSysClk, /*!< Core/system clock */ - kClockSdhcSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockSdhcSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockSdhcSrcExt /*!< External bypass clock (SDHC0_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sdhc_src_k53d10_t; -#else -} clock_sdhc_src_t; -#endif - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_k53d10_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief TSI Active Mode clock source */ -typedef enum _clock_tsi_active_mode_src -{ - kClockTsiActiveSrcBusClk, /*!< Bus clock */ - kClockTsiActiveSrcMcgIrClk, /*!< MCG IRC clock */ - kClockTsiActiveSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tsi_active_mode_src_k53d10_t; -#else -} clock_tsi_active_mode_src_t; -#endif - -/*! @brief TSI Low-power Mode clock source */ -typedef enum _clock_tsi_lp_mode_src -{ - kClockTsiLpSrcLpoClk, /*!< LPO clock */ - kClockTsiLpSrcEr32kClk /*!< ERCLK32K clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tsi_lp_mode_src_k53d10_t; -#else -} clock_tsi_lp_mode_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll = 0U, /*!< Fll clock */ - kClockPllFllSelPll = 1U, /*!< Pll0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_k53d10_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_k53d10_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlexbusClk = 0U, /*!< Flexbus clock */ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCG out clock */ - kClockClkoutSelRtc32kClk = 5U, /*!< RTC 32k clock */ - kClockClkoutSelOsc0erClk = 6U /*!< OSCERCLK0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_k53d10_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz /*!< 32kHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_k53d10_t; -#else -} clock_rtcout_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_k53d10_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_k53d10_t; -#else -} sim_usbvstby_mode_t; -#endif -#endif // FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_k53d10_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /*!< High speed comparator 0 output */ - kSimAdcTrgSelHighSpeedComp1 = 2U, /*!< High speed comparator 1 output */ - kSimAdcTrgSelHighSpeedComp2 = 3U, /*!< High speed comparator 2 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelPit2 = 6U, /*!< PIT trigger 2 */ - kSimAdcTrgSelPit3 = 7U, /*!< PIT trigger 3 */ - kSimAdcTrgSelFtm0 = 8U, /*!< FTM0 trigger */ - kSimAdcTrgSelFtm1 = 9U, /*!< FTM1 trigger */ - kSimAdcTrgSelFtm2 = 10U, /*!< FTM2 trigger */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_k53d10_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ - kSimUartRxsrcCmp1, /*!< CMP1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_k53d10_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcFtm1, /*!< UARTx_TX pin modulated with FTM1 channel 0 output */ - kSimUartTxsrcFtm2 /*!< UARTx_TX pin modulated with FTM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_k53d10_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM FlexTimer x trigger y select */ -typedef enum _sim_ftm_trg_src -{ - kSimFtmTrgSrc0, /*!< FlexTimer x trigger y select 0 */ - kSimFtmTrgSrc1 /*!< FlexTimer x trigger y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_trg_src_k53d10_t; -#else -} sim_ftm_trg_src_t; -#endif - -/*! @brief SIM FlexTimer external clock select */ -typedef enum _sim_ftm_clk_sel -{ - kSimFtmClkSel0, /*!< FTM CLKIN0 pin. */ - kSimFtmClkSel1 /*!< FTM CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_clk_sel_k53d10_t; -#else -} sim_ftm_clk_sel_t; -#endif - -/*! @brief SIM FlexTimer x channel y input capture source select */ -typedef enum _sim_ftm_ch_src -{ - kSimFtmChSrc0, /*!< FlexTimer x channel y input capture source 0. */ - kSimFtmChSrc1, /*!< FlexTimer x channel y input capture source 1. */ - kSimFtmChSrc2, /*!< FlexTimer x channel y input capture source 2. */ - kSimFtmChSrc3 /*!< FlexTimer x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_ch_src_k53d10_t; -#else -} sim_ftm_ch_src_t; -#endif - -/*! @brief SIM FlexTimer x Fault y select */ -typedef enum _sim_ftm_flt_sel -{ - kSimFtmFltSel0, /*!< FlexTimer x fault y select 0 */ - kSimFtmFltSel1 /*!< FlexTimer x fault y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_flt_sel_k53d10_t; -#else -} sim_ftm_flt_sel_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_k53d10_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1 /*!< CMP0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_k53d10_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM CMT/UART pad drive strength */ -typedef enum _sim_cmtuartpad_strengh -{ - kSimCmtuartSinglePad, /*!< Single-pad drive strength for CMT IRO or UART0_TXD */ - kSimCmtuartDualPad /*!< Dual-pad drive strength for CMT IRO or UART0_TXD */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_cmtuartpad_strengh_k53d10_t; -#else -} sim_cmtuartpad_strengh_t; -#endif - -/*! @brief SIM PTD7 pad drive strength */ -typedef enum _sim_ptd7pad_strengh -{ - kSimPtd7padSinglePad, /*!< Single-pad drive strength for PTD7 */ - kSimPtd7padDualPad /*!< Dual-pad drive strength for PTD7 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ptd7pad_strengh_k53d10_t; -#else -} sim_ptd7pad_strengh_t; -#endif - -/*! @brief SIM FlexBus security level */ -typedef enum _sim_flexbus_security_level -{ - kSimFbslLevel0, /*!< FlexBus security level 0. */ - kSimFbslLevel1, /*!< FlexBus security level 1. */ - kSimFbslLevel2, /*!< FlexBus security level 2. */ - kSimFbslLevel3, /*!< FlexBus security level 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_flexbus_security_level_k53d10_t; -#else -} sim_flexbus_security_level_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateUart4 = FSL_SIM_SCGC_BIT(1U, 10U), - kSimClockGateUart5 = FSL_SIM_SCGC_BIT(1U, 11U), -#if FSL_FEATURE_SOC_OPAMP_COUNT - kSimClockGateOpamp = FSL_SIM_SCGC_BIT(1U, 21U), -#endif -#if FSL_FEATURE_SOC_TRIAMP_COUNT - kSimClockGateTriamp = FSL_SIM_SCGC_BIT(1U, 24U), -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT - kSimClockGateEnet0 = FSL_SIM_SCGC_BIT(2U, 0U), -#endif - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(2U, 12U), - kSimClockGateDac1 = FSL_SIM_SCGC_BIT(2U, 13U), - -#if FSL_FEATURE_SOC_RNG_COUNT - kSimClockGateRnga0 = FSL_SIM_SCGC_BIT(3U, 0U), -#endif -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - kSimClockGateFlexcan1 = FSL_SIM_SCGC_BIT(3U, 4U), -#endif - kSimClockGateSpi2 = FSL_SIM_SCGC_BIT(3U, 12U), - kSimClockGateSdhc0 = FSL_SIM_SCGC_BIT(3U, 17U), - kSimClockGateFtm2 = FSL_SIM_SCGC_BIT(3U, 24U), - kSimClockGateAdc1 = FSL_SIM_SCGC_BIT(3U, 27U), -#if FSL_FEATURE_SOC_LCD_COUNT - kSimClockGateSlcd0 = FSL_SIM_SCGC_BIT(3U, 30U), -#endif - - kSimClockGateEwm0 = FSL_SIM_SCGC_BIT(4U, 1U), - kSimClockGateCmt0 = FSL_SIM_SCGC_BIT(4U, 2U), - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUart3 = FSL_SIM_SCGC_BIT(4U, 13U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), -#endif - kSimClockGateCmp = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateLlwu0 = FSL_SIM_SCGC_BIT(4U, 28U), - - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGateTsi0 = FSL_SIM_SCGC_BIT(5U, 5U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - kSimClockGateFlexcan0 = FSL_SIM_SCGC_BIT(6U, 4U), -#endif - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(6U, 12U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(6U, 13U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbdcd0 = FSL_SIM_SCGC_BIT(6U, 21U), -#endif - kSimClockGatePdb0 = FSL_SIM_SCGC_BIT(6U, 22U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateFtm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateFtm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - - kSimClockGateFlexbus0 = FSL_SIM_SCGC_BIT(7U, 0U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 1U), - kSimClockGateMpu0 = FSL_SIM_SCGC_BIT(7U, 2U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_k53d10_t; -#else -} sim_clock_gate_name_t; -#endif - -/*! @} */ -/******************************************************************************* - * API - ******************************************************************************/ - - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetSdhcSrc(SIM_Type * base, - uint32_t instance, - clock_sdhc_src_t setting) -{ - SIM_BWR_SOPT2_SDHCSRC(base, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_HAL_GetSdhcSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_sdhc_src_t)SIM_BRD_SOPT2_SDHCSRC(base); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTimeSrc(SIM_Type * base, - uint32_t instance, - clock_time_src_t setting) -{ - SIM_BWR_SOPT2_TIMESRC(base, setting); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_time_src_t CLOCK_HAL_GetTimeSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_time_src_t)SIM_BRD_SOPT2_TIMESRC(base); -} - -/*! - * @brief Set the Ethernet RMII interface clock source selection. - * - * This function sets the Ethernet RMII interface clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRmiiSrc(SIM_Type * base, - uint32_t instance, - clock_rmii_src_t setting) -{ - SIM_BWR_SOPT2_RMIISRC(base, setting); -} - -/*! - * @brief Get the Ethernet RMII interface clock source selection. - * - * This function gets the Ethernet RMII interface clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_rmii_src_t CLOCK_HAL_GetRmiiSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_rmii_src_t)SIM_BRD_SOPT2_RMIISRC(base); -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} -#endif - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set debug trace clock selection. - * - * This function sets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTraceClkSrc(SIM_Type * base, clock_trace_src_t setting) -{ - SIM_BWR_SOPT2_TRACECLKSEL(base, setting); -} - -/*! - * @brief Get debug trace clock selection. - * - * This function gets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_trace_src_t CLOCK_HAL_GetTraceClkSrc(SIM_Type * base) -{ - return (clock_trace_src_t)SIM_BRD_SOPT2_TRACECLKSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV2. - * - * This function sets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv2(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV2(base, setting); -} - -/*! - * @brief Get OUTDIV2. - * - * This function gets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv2(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV2(base); -} - -/*! - * @brief Set OUTDIV3. - * - * This function sets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv3(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV3(base, setting); -} - -/*! - * @brief Get OUTDIV3. - * - * This function gets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv3(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV3(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac); - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac); -#endif - -/*! - * @brief Gets RAM size. - * - * This function gets the RAM size. The field specifies the amount of system RAM - * available on the device. - * - * @param base Base address for current SIM instance. - * @return size RAM size on the device - */ -static inline uint32_t SIM_HAL_GetRamSize(SIM_Type * base) -{ - return SIM_BRD_SOPT1_RAMSIZE(base); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif - -/*! - * @brief Sets the PTD7 pad drive strength setting. - * - * This function controls the output drive strength of the PTD7 pin by selecting - * either one or two pads to drive it. - * - * @param base Base address for current SIM instance. - * @param setting PTD7 pad drive strength setting - * - 0: Single-pad drive strength for PTD7. - * - 1: Double pad drive strength for PTD7. - */ -static inline void SIM_HAL_SetPtd7PadDriveStrengthMode(SIM_Type * base, - sim_ptd7pad_strengh_t setting) -{ - SIM_BWR_SOPT2_PTD7PAD(base, setting); -} - -/*! - * @brief Gets the PTD7 pad drive strength setting. - * - * This function gets the PTD7 pad drive strength setting. - * - * @param base Base address for current SIM instance. - * @return setting PTD7 pad drive strength setting - */ -static inline sim_ptd7pad_strengh_t SIM_HAL_GetPtd7PadDriveStrengthMode(SIM_Type * base) -{ - return (sim_ptd7pad_strengh_t)SIM_BRD_SOPT2_PTD7PAD(base); -} - -/*! - * @brief Sets the FlexBus security level setting. - * - * This function sets the FlexBus security level setting. If the security is enabled, - * this field affects which CPU operations can access the off-chip via the FlexBus - * and DDR controller interfaces. This field has no effect if the security is not enabled. - * - * @param base Base address for current SIM instance. - * @param setting FlexBus security level setting - * - 00: All off-chip accesses (op code and data) via the FlexBus and - * DDR controller are disallowed. - * - 10: Off-chip op code accesses are disallowed. Data accesses are - * allowed. - * - 11: Off-chip op code accesses and data accesses are allowed. - */ -static inline void SIM_HAL_SetFlexbusSecurityLevelMode(SIM_Type * base, - sim_flexbus_security_level_t setting) -{ - SIM_BWR_SOPT2_FBSL(base, setting); -} - -/*! - * @brief Gets the FlexBus security level setting. - * - * This function gets the FlexBus security level setting. - * - * @param base Base address for current SIM instance. - * @return setting FlexBus security level setting - */ -static inline sim_flexbus_security_level_t SIM_HAL_GetFlexbusSecurityLevelMode(SIM_Type * base) -{ - return (sim_flexbus_security_level_t)SIM_BRD_SOPT2_FBSL(base); -} - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select); - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select); - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the FlexTimer x hardware trigger y source select setting. - * - * This function selects the source of FTMx hardware trigger y. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @param select FlexTimer x hardware trigger y - * - 0: Pre-trigger A selected for ADCx. - * - 1: Pre-trigger B selected for ADCx. - */ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select); - -/*! - * @brief Gets the FlexTimer x hardware trigger y source select setting. - * - * This function gets the FlexTimer x hardware trigger y source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @return select FlexTimer x hardware trigger y source select setting - */ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger); - -/*! - * @brief Sets the FlexTimer x external clock pin select setting. - * - * This function selects the source of FTMx external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select FTMx external clock pin select - * - 0: FTMx external clock driven by FTM CLKIN0 pin. - * - 1: FTMx external clock driven by FTM CLKIN1 pin. - */ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select); - -/*! - * @brief Gets the FlexTimer x external clock pin select setting. - * - * This function gets the FlexTimer x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select FlexTimer x external clock pin select setting - */ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the FlexTimer x channel y input capture source select setting. - * - * This function selects the FlexTimer x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y input capture source - */ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y input capture source select setting. - * - * This function gets the FlexTimer x channel y input capture - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y input capture source select setting - */ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Sets the FlexTimer x fault y select setting. - * - * This function sets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @param select FlexTimer x fault y select setting - * - 0: FlexTimer x fault y select 0. - * - 1: FlexTimer x fault y select 1. - */ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select); - -/*! - * @brief Gets the FlexTimer x fault y select setting. - * - * This function gets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @return select FlexTimer x fault y select setting - */ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault); - -/*! - * @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Fam ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Fam ID - */ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the FlexNVM size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size FlexNVM Size - */ -static inline uint32_t SIM_HAL_GetFlexnvmSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_NVMSIZE(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Gets the EEProm size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the EEProm size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size EEProm Size - */ -static inline uint32_t SIM_HAL_GetEepromSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_EESIZE(base); -} - -/*! - * @brief Gets the FlexNVM partition in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM partition in the Flash Configuration Register1 - * - * @param base Base address for current SIM instance. - * @return setting FlexNVM partition setting - */ -static inline uint32_t SIM_HAL_GetFlexnvmPartition(SIM_Type * base) -{ - return SIM_BRD_FCFG1_DEPART(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -/*! - * @brief Gets the program flash in the Flash Configuration Register 2. - * - * This function gets the program flash maximum block 0 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return status program flash status - */ -static inline uint32_t SIM_HAL_GetProgramFlashCmd(SIM_Type * base) -{ - return SIM_BRD_FCFG2_PFLSH(base); -} - -/*! - * @brief Gets the Swap program flash flag in the Flash Configuration Register 2. - * - * This function gets the Swap program flash flag in the Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return status - Swap program flash flag(Active or Inactive) - */ -static inline bool SIM_HAL_GetSwapProgramFlash(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG2_SWAPPFLSH(base); -} - - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ -/*! @}*/ - - -#endif /* __FSL_SIM_HAL_K53D10_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK60D10/fsl_sim_hal_MK60D10.c b/KSDK_1.2.0/platform/hal/src/sim/MK60D10/fsl_sim_hal_MK60D10.c deleted file mode 100755 index 46e1ed3..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK60D10/fsl_sim_hal_MK60D10.c +++ /dev/null @@ -1,750 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfDiv - * Description : Gets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} -#endif - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV3(outdiv3); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = SIM_BRD_CLKDIV1_OUTDIV3(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - SIM_BWR_SOPT4_FTM0FLT0(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0FLT1(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM0FLT2(base, select); - break; - default: - break; - } - break; - case 1: - SIM_BWR_SOPT4_FTM1FLT0(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2FLT0(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault) -{ - sim_ftm_flt_sel_t retValue = (sim_ftm_flt_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT0(base); - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT1(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT2(base); - break; - default: - break; - } - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM1FLT0(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM2FLT0(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK60D10/fsl_sim_hal_MK60D10.h b/KSDK_1.2.0/platform/hal/src/sim/MK60D10/fsl_sim_hal_MK60D10.h deleted file mode 100644 index e0e0432..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK60D10/fsl_sim_hal_MK60D10.h +++ /dev/null @@ -1,1731 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_K60D10_H__) -#define __FSL_SIM_HAL_K60D10_H__ - - -/*! - * @addtogroup sim_hal_k60d10 - * @{ - */ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief WDOG clock source select */ -typedef enum _clock_wdog_src_t -{ - kClockWdogSrcLpoClk, /*!< LPO */ - kClockWdogSrcAltClk /*!< Alternative clock, for K60D10 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_wdog_src_k60d10_t; -#else -} clock_wdog_src_t; -#endif - -/*! @brief Debug trace clock source select */ -typedef enum _clock_trace_src_t -{ - kClockTraceSrcMcgoutClk, /*!< MCG out clock */ - kClockTraceSrcCoreClk /*!< core clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_trace_src_k60d10_t; -#else -} clock_trace_src_t; -#endif - -/*! @brief PORTx digital input filter clock source select */ -typedef enum _clock_port_filter_src_t -{ - kClockPortFilterSrcBusClk, /*!< Bus clock */ - kClockPortFilterSrcLpoClk /*!< LPO */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_port_filter_src_k60d10_t; -#else -} clock_port_filter_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG IRC clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_k60d10_t; -#else -} clock_lptmr_src_t; -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! @brief SIM timestamp clock source */ -typedef enum _clock_time_src -{ - kClockTimeSrcCoreSysClk, /*!< Core/system clock */ - kClockTimeSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTimeSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTimeSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_time_src_k60d10_t; -#else -} clock_time_src_t; -#endif -#endif // FSL_FEATURE_SOC_ENET_COUNT - -/*! @brief SIM RMII clock source */ -typedef enum _clock_rmii_src -{ - kClockRmiiSrcExtalClk, /*!< EXTAL Clock */ - kClockRmiiSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rmii_src_k60d10_t; -#else -} clock_rmii_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcPllFllSel, /*!< Clock divider USB FS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_k60d10_t; -#else -} clock_usbfs_src_t; -#endif -#endif // FSL_FEATURE_SOC_USB_COUNT - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*! @brief FLEXCAN clock source select */ -typedef enum _clock_flexcan_src_t -{ - kClockFlexcanSrcOsc0erClk, /*!< OSCERCLK */ - kClockFlexcanSrcBusClk /*!< Bus clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_flexcan_src_k60d10_t; -#else -} clock_flexcan_src_t; -#endif -#endif // FSL_FEATURE_SOC_FLEXCAN_COUNT - -/*! @brief SDHC clock source */ -typedef enum _clock_sdhc_src -{ - kClockSdhcSrcCoreSysClk, /*!< Core/system clock */ - kClockSdhcSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockSdhcSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockSdhcSrcExt /*!< External bypass clock (SDHC0_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sdhc_src_k60d10_t; -#else -} clock_sdhc_src_t; -#endif - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_k60d10_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief TSI Active Mode clock source */ -typedef enum _clock_tsi_active_mode_src -{ - kClockTsiActiveSrcBusClk, /*!< Bus clock */ - kClockTsiActiveSrcMcgIrClk, /*!< MCG IRC clock */ - kClockTsiActiveSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tsi_active_mode_src_k60d10_t; -#else -} clock_tsi_active_mode_src_t; -#endif - -/*! @brief TSI Low-power Mode clock source */ -typedef enum _clock_tsi_lp_mode_src -{ - kClockTsiLpSrcLpoClk, /*!< LPO clock */ - kClockTsiLpSrcEr32kClk /*!< ERCLK32K clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tsi_lp_mode_src_k60d10_t; -#else -} clock_tsi_lp_mode_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll = 0U, /*!< Fll clock */ - kClockPllFllSelPll = 1U, /*!< Pll0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_k60d10_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_k60d10_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlexbusClk = 0U, /*!< Flexbus clock */ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCG out clock */ - kClockClkoutSelRtc32kClk = 5U, /*!< RTC 32k clock */ - kClockClkoutSelOsc0erClk = 6U /*!< OSCERCLK0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_k60d10_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz /*!< 32kHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_k60d10_t; -#else -} clock_rtcout_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_k60d10_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_k60d10_t; -#else -} sim_usbvstby_mode_t; -#endif -#endif // FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_k60d10_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /*!< High speed comparator 0 output */ - kSimAdcTrgSelHighSpeedComp1 = 2U, /*!< High speed comparator 1 output */ - kSimAdcTrgSelHighSpeedComp2 = 3U, /*!< High speed comparator 2 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelPit2 = 6U, /*!< PIT trigger 2 */ - kSimAdcTrgSelPit3 = 7U, /*!< PIT trigger 3 */ - kSimAdcTrgSelFtm0 = 8U, /*!< FTM0 trigger */ - kSimAdcTrgSelFtm1 = 9U, /*!< FTM1 trigger */ - kSimAdcTrgSelFtm2 = 10U, /*!< FTM2 trigger */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_k60d10_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ - kSimUartRxsrcCmp1, /*!< CMP1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_k60d10_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcFtm1, /*!< UARTx_TX pin modulated with FTM1 channel 0 output */ - kSimUartTxsrcFtm2 /*!< UARTx_TX pin modulated with FTM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_k60d10_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM FlexTimer x trigger y select */ -typedef enum _sim_ftm_trg_src -{ - kSimFtmTrgSrc0, /*!< FlexTimer x trigger y select 0 */ - kSimFtmTrgSrc1 /*!< FlexTimer x trigger y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_trg_src_k60d10_t; -#else -} sim_ftm_trg_src_t; -#endif - -/*! @brief SIM FlexTimer external clock select */ -typedef enum _sim_ftm_clk_sel -{ - kSimFtmClkSel0, /*!< FTM CLKIN0 pin. */ - kSimFtmClkSel1 /*!< FTM CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_clk_sel_k60d10_t; -#else -} sim_ftm_clk_sel_t; -#endif - -/*! @brief SIM FlexTimer x channel y input capture source select */ -typedef enum _sim_ftm_ch_src -{ - kSimFtmChSrc0, /*!< FlexTimer x channel y input capture source 0. */ - kSimFtmChSrc1, /*!< FlexTimer x channel y input capture source 1. */ - kSimFtmChSrc2, /*!< FlexTimer x channel y input capture source 2. */ - kSimFtmChSrc3 /*!< FlexTimer x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_ch_src_k60d10_t; -#else -} sim_ftm_ch_src_t; -#endif - -/*! @brief SIM FlexTimer x Fault y select */ -typedef enum _sim_ftm_flt_sel -{ - kSimFtmFltSel0, /*!< FlexTimer x fault y select 0 */ - kSimFtmFltSel1 /*!< FlexTimer x fault y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_flt_sel_k60d10_t; -#else -} sim_ftm_flt_sel_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_k60d10_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1 /*!< CMP0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_k60d10_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM CMT/UART pad drive strength */ -typedef enum _sim_cmtuartpad_strengh -{ - kSimCmtuartSinglePad, /*!< Single-pad drive strength for CMT IRO or UART0_TXD */ - kSimCmtuartDualPad /*!< Dual-pad drive strength for CMT IRO or UART0_TXD */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_cmtuartpad_strengh_k60d10_t; -#else -} sim_cmtuartpad_strengh_t; -#endif - -/*! @brief SIM PTD7 pad drive strength */ -typedef enum _sim_ptd7pad_strengh -{ - kSimPtd7padSinglePad, /*!< Single-pad drive strength for PTD7 */ - kSimPtd7padDualPad /*!< Dual-pad drive strength for PTD7 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ptd7pad_strengh_k60d10_t; -#else -} sim_ptd7pad_strengh_t; -#endif - -/*! @brief SIM FlexBus security level */ -typedef enum _sim_flexbus_security_level -{ - kSimFbslLevel0, /*!< FlexBus security level 0. */ - kSimFbslLevel1, /*!< FlexBus security level 1. */ - kSimFbslLevel2, /*!< FlexBus security level 2. */ - kSimFbslLevel3, /*!< FlexBus security level 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_flexbus_security_level_k60d10_t; -#else -} sim_flexbus_security_level_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateUart4 = FSL_SIM_SCGC_BIT(1U, 10U), - kSimClockGateUart5 = FSL_SIM_SCGC_BIT(1U, 11U), -#if FSL_FEATURE_SOC_OPAMP_COUNT - kSimClockGateOpamp = FSL_SIM_SCGC_BIT(1U, 21U), -#endif -#if FSL_FEATURE_SOC_TRIAMP_COUNT - kSimClockGateTriamp = FSL_SIM_SCGC_BIT(1U, 24U), -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT - kSimClockGateEnet0 = FSL_SIM_SCGC_BIT(2U, 0U), -#endif - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(2U, 12U), - kSimClockGateDac1 = FSL_SIM_SCGC_BIT(2U, 13U), - -#if FSL_FEATURE_SOC_RNG_COUNT - kSimClockGateRnga0 = FSL_SIM_SCGC_BIT(3U, 0U), -#endif -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - kSimClockGateFlexcan1 = FSL_SIM_SCGC_BIT(3U, 4U), -#endif - kSimClockGateSpi2 = FSL_SIM_SCGC_BIT(3U, 12U), - kSimClockGateSdhc0 = FSL_SIM_SCGC_BIT(3U, 17U), - kSimClockGateFtm2 = FSL_SIM_SCGC_BIT(3U, 24U), - kSimClockGateAdc1 = FSL_SIM_SCGC_BIT(3U, 27U), -#if FSL_FEATURE_SOC_LCD_COUNT - kSimClockGateSlcd0 = FSL_SIM_SCGC_BIT(3U, 30U), -#endif - - kSimClockGateEwm0 = FSL_SIM_SCGC_BIT(4U, 1U), - kSimClockGateCmt0 = FSL_SIM_SCGC_BIT(4U, 2U), - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUart3 = FSL_SIM_SCGC_BIT(4U, 13U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), -#endif - kSimClockGateCmp = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateLlwu0 = FSL_SIM_SCGC_BIT(4U, 28U), - - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGateTsi0 = FSL_SIM_SCGC_BIT(5U, 5U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - kSimClockGateFlexcan0 = FSL_SIM_SCGC_BIT(6U, 4U), -#endif - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(6U, 12U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(6U, 13U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbdcd0 = FSL_SIM_SCGC_BIT(6U, 21U), -#endif - kSimClockGatePdb0 = FSL_SIM_SCGC_BIT(6U, 22U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateFtm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateFtm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - - kSimClockGateFlexbus0 = FSL_SIM_SCGC_BIT(7U, 0U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 1U), - kSimClockGateMpu0 = FSL_SIM_SCGC_BIT(7U, 2U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_k60d10_t; -#else -} sim_clock_gate_name_t; -#endif - -/*! @} */ -/******************************************************************************* - * API - ******************************************************************************/ - - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetSdhcSrc(SIM_Type * base, - uint32_t instance, - clock_sdhc_src_t setting) -{ - SIM_BWR_SOPT2_SDHCSRC(base, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_HAL_GetSdhcSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_sdhc_src_t)SIM_BRD_SOPT2_SDHCSRC(base); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTimeSrc(SIM_Type * base, - uint32_t instance, - clock_time_src_t setting) -{ - SIM_BWR_SOPT2_TIMESRC(base, setting); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_time_src_t CLOCK_HAL_GetTimeSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_time_src_t)SIM_BRD_SOPT2_TIMESRC(base); -} - -/*! - * @brief Set the Ethernet RMII interface clock source selection. - * - * This function sets the Ethernet RMII interface clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRmiiSrc(SIM_Type * base, - uint32_t instance, - clock_rmii_src_t setting) -{ - SIM_BWR_SOPT2_RMIISRC(base, setting); -} - -/*! - * @brief Get the Ethernet RMII interface clock source selection. - * - * This function gets the Ethernet RMII interface clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_rmii_src_t CLOCK_HAL_GetRmiiSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_rmii_src_t)SIM_BRD_SOPT2_RMIISRC(base); -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} -#endif - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set debug trace clock selection. - * - * This function sets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTraceClkSrc(SIM_Type * base, clock_trace_src_t setting) -{ - SIM_BWR_SOPT2_TRACECLKSEL(base, setting); -} - -/*! - * @brief Get debug trace clock selection. - * - * This function gets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_trace_src_t CLOCK_HAL_GetTraceClkSrc(SIM_Type * base) -{ - return (clock_trace_src_t)SIM_BRD_SOPT2_TRACECLKSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV2. - * - * This function sets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv2(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV2(base, setting); -} - -/*! - * @brief Get OUTDIV2. - * - * This function gets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv2(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV2(base); -} - -/*! - * @brief Set OUTDIV3. - * - * This function sets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv3(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV3(base, setting); -} - -/*! - * @brief Get OUTDIV3. - * - * This function gets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv3(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV3(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac); - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac); -#endif - -/*! - * @brief Gets RAM size. - * - * This function gets the RAM size. The field specifies the amount of system RAM - * available on the device. - * - * @param base Base address for current SIM instance. - * @return size RAM size on the device - */ -static inline uint32_t SIM_HAL_GetRamSize(SIM_Type * base) -{ - return SIM_BRD_SOPT1_RAMSIZE(base); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif - -/*! - * @brief Sets the PTD7 pad drive strength setting. - * - * This function controls the output drive strength of the PTD7 pin by selecting - * either one or two pads to drive it. - * - * @param base Base address for current SIM instance. - * @param setting PTD7 pad drive strength setting - * - 0: Single-pad drive strength for PTD7. - * - 1: Double pad drive strength for PTD7. - */ -static inline void SIM_HAL_SetPtd7PadDriveStrengthMode(SIM_Type * base, - sim_ptd7pad_strengh_t setting) -{ - SIM_BWR_SOPT2_PTD7PAD(base, setting); -} - -/*! - * @brief Gets the PTD7 pad drive strength setting. - * - * This function gets the PTD7 pad drive strength setting. - * - * @param base Base address for current SIM instance. - * @return setting PTD7 pad drive strength setting - */ -static inline sim_ptd7pad_strengh_t SIM_HAL_GetPtd7PadDriveStrengthMode(SIM_Type * base) -{ - return (sim_ptd7pad_strengh_t)SIM_BRD_SOPT2_PTD7PAD(base); -} - -/*! - * @brief Sets the FlexBus security level setting. - * - * This function sets the FlexBus security level setting. If the security is enabled, - * this field affects which CPU operations can access the off-chip via the FlexBus - * and DDR controller interfaces. This field has no effect if the security is not enabled. - * - * @param base Base address for current SIM instance. - * @param setting FlexBus security level setting - * - 00: All off-chip accesses (op code and data) via the FlexBus and - * DDR controller are disallowed. - * - 10: Off-chip op code accesses are disallowed. Data accesses are - * allowed. - * - 11: Off-chip op code accesses and data accesses are allowed. - */ -static inline void SIM_HAL_SetFlexbusSecurityLevelMode(SIM_Type * base, - sim_flexbus_security_level_t setting) -{ - SIM_BWR_SOPT2_FBSL(base, setting); -} - -/*! - * @brief Gets the FlexBus security level setting. - * - * This function gets the FlexBus security level setting. - * - * @param base Base address for current SIM instance. - * @return setting FlexBus security level setting - */ -static inline sim_flexbus_security_level_t SIM_HAL_GetFlexbusSecurityLevelMode(SIM_Type * base) -{ - return (sim_flexbus_security_level_t)SIM_BRD_SOPT2_FBSL(base); -} - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select); - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select); - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the FlexTimer x hardware trigger y source select setting. - * - * This function selects the source of FTMx hardware trigger y. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @param select FlexTimer x hardware trigger y - * - 0: Pre-trigger A selected for ADCx. - * - 1: Pre-trigger B selected for ADCx. - */ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select); - -/*! - * @brief Gets the FlexTimer x hardware trigger y source select setting. - * - * This function gets the FlexTimer x hardware trigger y source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @return select FlexTimer x hardware trigger y source select setting - */ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger); - -/*! - * @brief Sets the FlexTimer x external clock pin select setting. - * - * This function selects the source of FTMx external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select FTMx external clock pin select - * - 0: FTMx external clock driven by FTM CLKIN0 pin. - * - 1: FTMx external clock driven by FTM CLKIN1 pin. - */ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select); - -/*! - * @brief Gets the FlexTimer x external clock pin select setting. - * - * This function gets the FlexTimer x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select FlexTimer x external clock pin select setting - */ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the FlexTimer x channel y input capture source select setting. - * - * This function selects the FlexTimer x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y input capture source - */ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y input capture source select setting. - * - * This function gets the FlexTimer x channel y input capture - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y input capture source select setting - */ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Sets the FlexTimer x fault y select setting. - * - * This function sets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @param select FlexTimer x fault y select setting - * - 0: FlexTimer x fault y select 0. - * - 1: FlexTimer x fault y select 1. - */ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select); - -/*! - * @brief Gets the FlexTimer x fault y select setting. - * - * This function gets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @return select FlexTimer x fault y select setting - */ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault); - -/*! - * @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Fam ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Fam ID - */ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the FlexNVM size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size FlexNVM Size - */ -static inline uint32_t SIM_HAL_GetFlexnvmSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_NVMSIZE(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Gets the EEProm size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the EEProm size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size EEProm Size - */ -static inline uint32_t SIM_HAL_GetEepromSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_EESIZE(base); -} - -/*! - * @brief Gets the FlexNVM partition in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM partition in the Flash Configuration Register1 - * - * @param base Base address for current SIM instance. - * @return setting FlexNVM partition setting - */ -static inline uint32_t SIM_HAL_GetFlexnvmPartition(SIM_Type * base) -{ - return SIM_BRD_FCFG1_DEPART(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -/*! - * @brief Gets the program flash in the Flash Configuration Register 2. - * - * This function gets the program flash maximum block 0 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return status program flash status - */ -static inline uint32_t SIM_HAL_GetProgramFlashCmd(SIM_Type * base) -{ - return SIM_BRD_FCFG2_PFLSH(base); -} - -/*! - * @brief Gets the Swap program flash flag in the Flash Configuration Register 2. - * - * This function gets the Swap program flash flag in the Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return status - Swap program flash flag(Active or Inactive) - */ -static inline bool SIM_HAL_GetSwapProgramFlash(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG2_SWAPPFLSH(base); -} - - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ -/*! @}*/ - - -#endif /* __FSL_SIM_HAL_K60D10_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK63F12/fsl_sim_hal_MK63F12.c b/KSDK_1.2.0/platform/hal/src/sim/MK63F12/fsl_sim_hal_MK63F12.c deleted file mode 100755 index e78a1ef..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK63F12/fsl_sim_hal_MK63F12.c +++ /dev/null @@ -1,786 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB devider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfDiv - * Description : Gets USB devider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV3(outdiv3); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = SIM_BRD_CLKDIV1_OUTDIV3(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - case 3: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM3TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM3TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - case 3: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM3TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM3TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - case 3: - SIM_BWR_SOPT4_FTM3CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - case 3: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM3CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - SIM_BWR_SOPT4_FTM0FLT0(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0FLT1(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM0FLT2(base, select); - break; - default: - break; - } - break; - case 1: - SIM_BWR_SOPT4_FTM1FLT0(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2FLT0(base, select); - break; - case 3: - SIM_BWR_SOPT4_FTM3FLT0(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault) -{ - sim_ftm_flt_sel_t retValue = (sim_ftm_flt_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT0(base); - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT1(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT2(base); - break; - default: - break; - } - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM1FLT0(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM2FLT0(base); - break; - case 3: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM3FLT0(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK63F12/fsl_sim_hal_MK63F12.h b/KSDK_1.2.0/platform/hal/src/sim/MK63F12/fsl_sim_hal_MK63F12.h deleted file mode 100644 index bc3353c..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK63F12/fsl_sim_hal_MK63F12.h +++ /dev/null @@ -1,1704 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_MK63F12_H__) -#define __FSL_SIM_HAL_MK63F12_H__ - -/*! - * @addtogroup sim_hal_k63f12 - * @{ - */ -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief WDOG clock source select */ -typedef enum _clock_wdog_src_t -{ - kClockWdogSrcLpoClk, /*!< LPO */ - kClockWdogSrcAltClk, /*!< Alternative clock, for MK63F12 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_wdog_src_k63f12_t; -#else -} clock_wdog_src_t; -#endif - -/*! @brief Debug trace clock source select */ -typedef enum _clock_trace_src_t -{ - kClockTraceSrcMcgoutClk, /*!< MCG out clock */ - kClockTraceSrcCoreClk, /*!< core clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_trace_src_k63f12_t; -#else -} clock_trace_src_t; -#endif - -/*! @brief PORTx digital input filter clock source select */ -typedef enum _clock_port_filter_src_t -{ - kClockPortFilterSrcBusClk, /*!< Bus clock */ - kClockPortFilterSrcLpoClk, /*!< LPO */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_port_filter_src_k63f12_t; -#else -} clock_port_filter_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCGIRCLK */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk, /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_k63f12_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief SIM timestamp clock source */ -typedef enum _clock_time_src -{ - kClockTimeSrcCoreSysClk, /*!< Core/system clock */ - kClockTimeSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTimeSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTimeSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_time_src_k63f12_t; -#else -} clock_time_src_t; -#endif - -/*! @brief SIM RMII clock source */ -typedef enum _clock_rmii_src -{ - kClockRmiiSrcExtalClk, /*!< EXTAL Clock */ - kClockRmiiSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rmii_src_k63f12_t; -#else -} clock_rmii_src_t; -#endif - -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcPllFllSel, /*!< Clock divider USB FS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_k63f12_t; -#else -} clock_usbfs_src_t; -#endif - -/*! @brief FLEXCAN clock source select */ -typedef enum _clock_flexcan_src_t -{ - kClockFlexcanSrcOsc0erClk, /*!< OSCERCLK */ - kClockFlexcanSrcBusClk /*!< Bus clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_flexcan_src_k63f12_t; -#else -} clock_flexcan_src_t; -#endif - -/*! @brief SDHC clock source */ -typedef enum _clock_sdhc_src -{ - kClockSdhcSrcCoreSysClk, /*!< Core/system clock */ - kClockSdhcSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockSdhcSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockSdhcSrcExt /*!< External bypass clock (SDHC0_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sdhc_src_k63f12_t; -#else -} clock_sdhc_src_t; -#endif - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_k63f12_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll = 0U, /*!< Fll clock */ - kClockPllFllSelPll = 1U, /*!< Pll0 clock */ - kClockPllFllSelIrc48M = 3U /*!< IRC48MCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_k63f12_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U, /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_k63f12_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlexbusClk = 0U, /*!< Flexbus clock */ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCGIRCLK */ - kClockClkoutSelRtc = 5U, /*!< RTC 32k clock */ - kClockClkoutSelOsc0erClk = 6U, /*!< OSC0ERCLK */ - kClockClkoutSelIrc48M = 7U, /*!< IRC48MCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_k63f12_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz, /*!< 32kHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_k63f12_t; -#else -} clock_rtcout_src_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_k63f12_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_k63f12_t; -#else -} sim_usbvstby_mode_t; -#endif - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_k63f12_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /*!< High speed comparator 0 output */ - kSimAdcTrgSelHighSpeedComp1 = 2U, /*!< High speed comparator 1 output */ - kSimAdcTrgSelHighSpeedComp2 = 3U, /*!< High speed comparator 2 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelPit2 = 6U, /*!< PIT trigger 2 */ - kSimAdcTrgSelPit3 = 7U, /*!< PIT trigger 3 */ - kSimAdcTrgSelFtm0 = 8U, /*!< FTM0 trigger */ - kSimAdcTrgSelFtm1 = 9U, /*!< FTM1 trigger */ - kSimAdcTrgSelFtm2 = 10U, /*!< FTM2 trigger */ - kSimAdcTrgSelFtm3 = 11U, /*!< FTM3 trigger */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U, /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_k63f12_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ - kSimUartRxsrcCmp1, /*!< CMP1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_k63f12_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcFtm1, /*!< UARTx_TX pin modulated with FTM1 channel 0 output */ - kSimUartTxsrcFtm2, /*!< UARTx_TX pin modulated with FTM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_k63f12_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM FlexTimer x trigger y select */ -typedef enum _sim_ftm_trg_src -{ - kSimFtmTrgSrc0, /*!< FlexTimer x trigger y select 0 */ - kSimFtmTrgSrc1 /*!< FlexTimer x trigger y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_trg_src_k63f12_t; -#else -} sim_ftm_trg_src_t; -#endif - -/*! @brief SIM FlexTimer external clock select */ -typedef enum _sim_ftm_clk_sel -{ - kSimFtmClkSel0, /*!< FTM CLKIN0 pin. */ - kSimFtmClkSel1 /*!< FTM CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_clk_sel_k63f12_t; -#else -} sim_ftm_clk_sel_t; -#endif - -/*! @brief SIM FlexTimer x channel y input capture source select */ -typedef enum _sim_ftm_ch_src -{ - kSimFtmChSrc0, /*!< FlexTimer x channel y input capture source 0. */ - kSimFtmChSrc1, /*!< FlexTimer x channel y input capture source 1. */ - kSimFtmChSrc2, /*!< FlexTimer x channel y input capture source 2. */ - kSimFtmChSrc3, /*!< FlexTimer x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_ch_src_k63f12_t; -#else -} sim_ftm_ch_src_t; -#endif - -/*! @brief SIM FlexTimer x Fault y select */ -typedef enum _sim_ftm_flt_sel -{ - kSimFtmFltSel0, /*!< FlexTimer x fault y select 0 */ - kSimFtmFltSel1 /*!< FlexTimer x fault y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_flt_sel_k63f12_t; -#else -} sim_ftm_flt_sel_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_k63f12_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPM x channel y input capture source 0. */ - kSimTpmChSrc1, /*!< TPM x channel y input capture source 1. */ - kSimTpmChSrc2, /*!< TPM x channel y input capture source 2. */ - kSimTpmChSrc3, /*!< TPM x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_k63f12_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM CMT/UART pad drive strength */ -typedef enum _sim_cmtuartpad_strengh -{ - kSimCmtuartSinglePad, /*!< Single-pad drive strength for CMT IRO or UART0_TXD */ - kSimCmtuartDualPad /*!< Dual-pad drive strength for CMT IRO or UART0_TXD */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_cmtuartpad_strengh_k63f12_t; -#else -} sim_cmtuartpad_strengh_t; -#endif - -/*! @brief SIM PTD7 pad drive strength */ -typedef enum _sim_ptd7pad_strengh -{ - kSimPtd7padSinglePad, /*!< Single-pad drive strength for PTD7 */ - kSimPtd7padDualPad /*!< Dual-pad drive strength for PTD7 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ptd7pad_strengh_k63f12_t; -#else -} sim_ptd7pad_strengh_t; -#endif - -/*! @brief SIM FlexBus security level */ -typedef enum _sim_flexbus_security_level -{ - kSimFbslLevel0, /*!< FlexBus security level 0. */ - kSimFbslLevel1, /*!< FlexBus security level 1. */ - kSimFbslLevel2, /*!< FlexBus security level 2. */ - kSimFbslLevel3, /*!< FlexBus security level 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_flexbus_security_level_k63f12_t; -#else -} sim_flexbus_security_level_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateI2c2 = FSL_SIM_SCGC_BIT(1U, 6U), - kSimClockGateUart4 = FSL_SIM_SCGC_BIT(1U, 10U), - kSimClockGateUart5 = FSL_SIM_SCGC_BIT(1U, 11U), - kSimClockGateEnet0 = FSL_SIM_SCGC_BIT(2U, 0U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(2U, 12U), - kSimClockGateDac1 = FSL_SIM_SCGC_BIT(2U, 13U), - kSimClockGateSpi2 = FSL_SIM_SCGC_BIT(3U, 12U), - kSimClockGateSdhc0 = FSL_SIM_SCGC_BIT(3U, 17U), - kSimClockGateFtm3 = FSL_SIM_SCGC_BIT(3U, 25U), - kSimClockGateAdc1 = FSL_SIM_SCGC_BIT(3U, 27U), - kSimClockGateEwm0 = FSL_SIM_SCGC_BIT(4U, 1U), - kSimClockGateCmt0 = FSL_SIM_SCGC_BIT(4U, 2U), - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUart3 = FSL_SIM_SCGC_BIT(4U, 13U), - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), - kSimClockGateCmp = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateFlexcan0 = FSL_SIM_SCGC_BIT(6U, 4U), - kSimClockGateRnga0 = FSL_SIM_SCGC_BIT(6U, 9U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(6U, 12U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(6U, 13U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), - kSimClockGateUsbdcd0 = FSL_SIM_SCGC_BIT(6U, 21U), - kSimClockGatePdb0 = FSL_SIM_SCGC_BIT(6U, 22U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateFtm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateFtm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateFtm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateFlexbus0 = FSL_SIM_SCGC_BIT(7U, 0U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 1U), - kSimClockGateMpu0 = FSL_SIM_SCGC_BIT(7U, 2U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_k63f12_t; -#else -} sim_clock_gate_name_t; -#endif - -/*@}*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetSdhcSrc(SIM_Type * base, - uint32_t instance, - clock_sdhc_src_t setting) -{ - SIM_BWR_SOPT2_SDHCSRC(base, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_HAL_GetSdhcSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_sdhc_src_t)SIM_BRD_SOPT2_SDHCSRC(base); -} - -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTimeSrc(SIM_Type * base, - uint32_t instance, - clock_time_src_t setting) -{ - SIM_BWR_SOPT2_TIMESRC(base, setting); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_time_src_t CLOCK_HAL_GetTimeSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_time_src_t)SIM_BRD_SOPT2_TIMESRC(base); -} - -/*! - * @brief Set the Ethernet RMII interface clock source selection. - * - * This function sets the Ethernet RMII interface clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRmiiSrc(SIM_Type * base, - uint32_t instance, - clock_rmii_src_t setting) -{ - SIM_BWR_SOPT2_RMIISRC(base, setting); -} - -/*! - * @brief Get the Ethernet RMII interface clock source selection. - * - * This function gets the Ethernet RMII interface clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_rmii_src_t CLOCK_HAL_GetRmiiSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_rmii_src_t)SIM_BRD_SOPT2_RMIISRC(base); -} - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac); - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac); - - -/*! - * @brief Set debug trace clock selection. - * - * This function sets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTraceClkSrc(SIM_Type * base, clock_trace_src_t setting) -{ - SIM_BWR_SOPT2_TRACECLKSEL(base, setting); -} - -/*! - * @brief Get debug trace clock selection. - * - * This function gets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_trace_src_t CLOCK_HAL_GetTraceClkSrc(SIM_Type * base) -{ - return (clock_trace_src_t)SIM_BRD_SOPT2_TRACECLKSEL(base); -} - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV2. - * - * This function sets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv2(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV2(base, setting); -} - -/*! - * @brief Get OUTDIV2. - * - * This function gets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv2(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV2(base); -} - -/*! - * @brief Set OUTDIV3. - * - * This function sets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv3(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV3(base, setting); -} - -/*! - * @brief Get OUTDIV3. - * - * This function gets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv3(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV3(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); -/*! - * @brief Gets RAM size. - * - * This function gets the RAM size. The field specifies the amount of system RAM - * available on the device. - * - * @param base Base address for current SIM instance. - * @return size RAM size on the device - */ -static inline uint32_t SIM_HAL_GetRamSize(SIM_Type * base) -{ - return SIM_BRD_SOPT1_RAMSIZE(base); -} - -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} - -/*! - * @brief Sets the PTD7 pad drive strength setting. - * - * This function controls the output drive strength of the PTD7 pin by selecting - * either one or two pads to drive it. - * - * @param base Base address for current SIM instance. - * @param setting PTD7 pad drive strength setting - * - 0: Single-pad drive strength for PTD7. - * - 1: Double pad drive strength for PTD7. - */ -static inline void SIM_HAL_SetPtd7PadDriveStrengthMode(SIM_Type * base, - sim_ptd7pad_strengh_t setting) -{ - SIM_BWR_SOPT2_PTD7PAD(base, setting); -} - -/*! - * @brief Gets the PTD7 pad drive strength setting. - * - * This function gets the PTD7 pad drive strength setting. - * - * @param base Base address for current SIM instance. - * @return setting PTD7 pad drive strength setting - */ -static inline sim_ptd7pad_strengh_t SIM_HAL_GetPtd7PadDriveStrengthMode(SIM_Type * base) -{ - return (sim_ptd7pad_strengh_t)SIM_BRD_SOPT2_PTD7PAD(base); -} - -/*! - * @brief Sets the FlexBus security level setting. - * - * This function sets the FlexBus security level setting. If the security is enabled, - * this field affects which CPU operations can access the off-chip via the FlexBus - * and DDR controller interfaces. This field has no effect if the security is not enabled. - * - * @param base Base address for current SIM instance. - * @param setting FlexBus security level setting - * - 00: All off-chip accesses (op code and data) via the FlexBus and - * DDR controller are disallowed. - * - 10: Off-chip op code accesses are disallowed. Data accesses are - * allowed. - * - 11: Off-chip op code accesses and data accesses are allowed. - */ -static inline void SIM_HAL_SetFlexbusSecurityLevelMode(SIM_Type * base, - sim_flexbus_security_level_t setting) -{ - SIM_BWR_SOPT2_FBSL(base, setting); -} - -/*! - * @brief Gets the FlexBus security level setting. - * - * This function gets the FlexBus security level setting. - * - * @param base Base address for current SIM instance. - * @return setting FlexBus security level setting - */ -static inline sim_flexbus_security_level_t SIM_HAL_GetFlexbusSecurityLevelMode(SIM_Type * base) -{ - return (sim_flexbus_security_level_t)SIM_BRD_SOPT2_FBSL(base); -} - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select); - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select); - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the FlexTimer x hardware trigger y source select setting. - * - * This function selects the source of FTMx hardware trigger y. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @param select FlexTimer x hardware trigger y - * - 0: Pre-trigger A selected for ADCx. - * - 1: Pre-trigger B selected for ADCx. - */ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select); - -/*! - * @brief Gets the FlexTimer x hardware trigger y source select setting. - * - * This function gets the FlexTimer x hardware trigger y source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @return select FlexTimer x hardware trigger y source select setting - */ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger); - -/*! - * @brief Sets the FlexTimer x external clock pin select setting. - * - * This function selects the source of FTMx external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select FTMx external clock pin select - * - 0: FTMx external clock driven by FTM CLKIN0 pin. - * - 1: FTMx external clock driven by FTM CLKIN1 pin. - */ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select); - -/*! - * @brief Gets the FlexTimer x external clock pin select setting. - * - * This function gets the FlexTimer x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select FlexTimer x external clock pin select setting - */ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the FlexTimer x channel y input capture source select setting. - * - * This function selects the FlexTimer x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y input capture source - */ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y input capture source select setting. - * - * This function gets the FlexTimer x channel y input capture - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y input capture source select setting - */ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Sets the FlexTimer x fault y select setting. - * - * This function sets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @param select FlexTimer x fault y select setting - * - 0: FlexTimer x fault y select 0. - * - 1: FlexTimer x fault y select 1. - */ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select); - -/*! - * @brief Gets the FlexTimer x fault y select setting. - * - * This function gets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @return select FlexTimer x fault y select setting - */ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault); - -/*! - * @brief Gets the Kinetis Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Family ID in the System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Family ID - */ -static inline uint32_t SIM_HAL_GetFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMILYID(base); -} - -/*! - * @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Sub-Family ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Sub-Family ID - */ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} - -/*! - * @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Series ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Series ID - */ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type * base) -{ - return SIM_BRD_SDID_SERIESID(base); -} - -/*! - * @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Fam ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Fam ID - */ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the Kinetis Die ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Die ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Die ID - */ -static inline uint32_t SIM_HAL_GetDieId(SIM_Type * base) -{ - return SIM_BRD_SDID_DIEID(base); -} - -/*! - * @brief Gets the FlexNVM size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size FlexNVM Size - */ -static inline uint32_t SIM_HAL_GetFlexnvmSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_NVMSIZE(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Gets the EEProm size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the EEProm size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size EEProm Size - */ -static inline uint32_t SIM_HAL_GetEepromSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_EESIZE(base); -} - -/*! - * @brief Gets the FlexNVM partition in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM partition in the Flash Configuration Register1 - * - * @param base Base address for current SIM instance. - * @return setting FlexNVM partition setting - */ -static inline uint32_t SIM_HAL_GetFlexnvmPartition(SIM_Type * base) -{ - return SIM_BRD_FCFG1_DEPART(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -/*! - * @brief Gets the program flash in the Flash Configuration Register 2. - * - * This function gets the program flash maximum block 0 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return status program flash status - */ -static inline uint32_t SIM_HAL_GetProgramFlashCmd(SIM_Type * base) -{ - return SIM_BRD_FCFG2_PFLSH(base); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_SIM_HAL_MK63F12_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK64F12/fsl_sim_hal_MK64F12.c b/KSDK_1.2.0/platform/hal/src/sim/MK64F12/fsl_sim_hal_MK64F12.c deleted file mode 100755 index e78a1ef..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK64F12/fsl_sim_hal_MK64F12.c +++ /dev/null @@ -1,786 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB devider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfDiv - * Description : Gets USB devider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV3(outdiv3); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = SIM_BRD_CLKDIV1_OUTDIV3(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - case 3: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM3TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM3TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - case 3: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM3TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM3TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - case 3: - SIM_BWR_SOPT4_FTM3CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - case 3: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM3CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - SIM_BWR_SOPT4_FTM0FLT0(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0FLT1(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM0FLT2(base, select); - break; - default: - break; - } - break; - case 1: - SIM_BWR_SOPT4_FTM1FLT0(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2FLT0(base, select); - break; - case 3: - SIM_BWR_SOPT4_FTM3FLT0(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault) -{ - sim_ftm_flt_sel_t retValue = (sim_ftm_flt_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT0(base); - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT1(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT2(base); - break; - default: - break; - } - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM1FLT0(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM2FLT0(base); - break; - case 3: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM3FLT0(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK64F12/fsl_sim_hal_MK64F12.h b/KSDK_1.2.0/platform/hal/src/sim/MK64F12/fsl_sim_hal_MK64F12.h deleted file mode 100644 index 6e8e4d9..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK64F12/fsl_sim_hal_MK64F12.h +++ /dev/null @@ -1,1704 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_K64F12_H__) -#define __FSL_SIM_HAL_K64F12_H__ - -/*! - * @addtogroup sim_hal_k64f12 - * @{ - */ -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief WDOG clock source select */ -typedef enum _clock_wdog_src_t -{ - kClockWdogSrcLpoClk, /*!< LPO */ - kClockWdogSrcAltClk, /*!< Alternative clock, for K64F12 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_wdog_src_k64f12_t; -#else -} clock_wdog_src_t; -#endif - -/*! @brief Debug trace clock source select */ -typedef enum _clock_trace_src_t -{ - kClockTraceSrcMcgoutClk, /*!< MCG out clock */ - kClockTraceSrcCoreClk, /*!< core clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_trace_src_k64f12_t; -#else -} clock_trace_src_t; -#endif - -/*! @brief PORTx digital input filter clock source select */ -typedef enum _clock_port_filter_src_t -{ - kClockPortFilterSrcBusClk, /*!< Bus clock */ - kClockPortFilterSrcLpoClk, /*!< LPO */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_port_filter_src_k64f12_t; -#else -} clock_port_filter_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCGIRCLK */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk, /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_k64f12_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief SIM timestamp clock source */ -typedef enum _clock_time_src -{ - kClockTimeSrcCoreSysClk, /*!< Core/system clock */ - kClockTimeSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTimeSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTimeSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_time_src_k64f12_t; -#else -} clock_time_src_t; -#endif - -/*! @brief SIM RMII clock source */ -typedef enum _clock_rmii_src -{ - kClockRmiiSrcExtalClk, /*!< EXTAL Clock */ - kClockRmiiSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rmii_src_k64f12_t; -#else -} clock_rmii_src_t; -#endif - -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcPllFllSel, /*!< Clock divider USB FS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_k64f12_t; -#else -} clock_usbfs_src_t; -#endif - -/*! @brief FLEXCAN clock source select */ -typedef enum _clock_flexcan_src_t -{ - kClockFlexcanSrcOsc0erClk, /*!< OSCERCLK */ - kClockFlexcanSrcBusClk /*!< Bus clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_flexcan_src_k64f12_t; -#else -} clock_flexcan_src_t; -#endif - -/*! @brief SDHC clock source */ -typedef enum _clock_sdhc_src -{ - kClockSdhcSrcCoreSysClk, /*!< Core/system clock */ - kClockSdhcSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockSdhcSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockSdhcSrcExt /*!< External bypass clock (SDHC0_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sdhc_src_k64f12_t; -#else -} clock_sdhc_src_t; -#endif - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_k64f12_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll = 0U, /*!< Fll clock */ - kClockPllFllSelPll = 1U, /*!< Pll0 clock */ - kClockPllFllSelIrc48M = 3U /*!< IRC48MCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_k64f12_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U, /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_k64f12_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlexbusClk = 0U, /*!< Flexbus clock */ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCGIRCLK */ - kClockClkoutSelRtc = 5U, /*!< RTC 32k clock */ - kClockClkoutSelOsc0erClk = 6U, /*!< OSC0ERCLK */ - kClockClkoutSelIrc48M = 7U, /*!< IRC48MCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_k64f12_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz, /*!< 32kHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_k64f12_t; -#else -} clock_rtcout_src_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_k64f12_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_k64f12_t; -#else -} sim_usbvstby_mode_t; -#endif - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_k64f12_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /*!< High speed comparator 0 output */ - kSimAdcTrgSelHighSpeedComp1 = 2U, /*!< High speed comparator 1 output */ - kSimAdcTrgSelHighSpeedComp2 = 3U, /*!< High speed comparator 2 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelPit2 = 6U, /*!< PIT trigger 2 */ - kSimAdcTrgSelPit3 = 7U, /*!< PIT trigger 3 */ - kSimAdcTrgSelFtm0 = 8U, /*!< FTM0 trigger */ - kSimAdcTrgSelFtm1 = 9U, /*!< FTM1 trigger */ - kSimAdcTrgSelFtm2 = 10U, /*!< FTM2 trigger */ - kSimAdcTrgSelFtm3 = 11U, /*!< FTM3 trigger */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U, /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_k64f12_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ - kSimUartRxsrcCmp1, /*!< CMP1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_k64f12_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcFtm1, /*!< UARTx_TX pin modulated with FTM1 channel 0 output */ - kSimUartTxsrcFtm2, /*!< UARTx_TX pin modulated with FTM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_k64f12_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM FlexTimer x trigger y select */ -typedef enum _sim_ftm_trg_src -{ - kSimFtmTrgSrc0, /*!< FlexTimer x trigger y select 0 */ - kSimFtmTrgSrc1 /*!< FlexTimer x trigger y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_trg_src_k64f12_t; -#else -} sim_ftm_trg_src_t; -#endif - -/*! @brief SIM FlexTimer external clock select */ -typedef enum _sim_ftm_clk_sel -{ - kSimFtmClkSel0, /*!< FTM CLKIN0 pin. */ - kSimFtmClkSel1 /*!< FTM CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_clk_sel_k64f12_t; -#else -} sim_ftm_clk_sel_t; -#endif - -/*! @brief SIM FlexTimer x channel y input capture source select */ -typedef enum _sim_ftm_ch_src -{ - kSimFtmChSrc0, /*!< FlexTimer x channel y input capture source 0. */ - kSimFtmChSrc1, /*!< FlexTimer x channel y input capture source 1. */ - kSimFtmChSrc2, /*!< FlexTimer x channel y input capture source 2. */ - kSimFtmChSrc3, /*!< FlexTimer x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_ch_src_k64f12_t; -#else -} sim_ftm_ch_src_t; -#endif - -/*! @brief SIM FlexTimer x Fault y select */ -typedef enum _sim_ftm_flt_sel -{ - kSimFtmFltSel0, /*!< FlexTimer x fault y select 0 */ - kSimFtmFltSel1 /*!< FlexTimer x fault y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_flt_sel_k64f12_t; -#else -} sim_ftm_flt_sel_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_k64f12_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPM x channel y input capture source 0. */ - kSimTpmChSrc1, /*!< TPM x channel y input capture source 1. */ - kSimTpmChSrc2, /*!< TPM x channel y input capture source 2. */ - kSimTpmChSrc3, /*!< TPM x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_k64f12_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM CMT/UART pad drive strength */ -typedef enum _sim_cmtuartpad_strengh -{ - kSimCmtuartSinglePad, /*!< Single-pad drive strength for CMT IRO or UART0_TXD */ - kSimCmtuartDualPad /*!< Dual-pad drive strength for CMT IRO or UART0_TXD */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_cmtuartpad_strengh_k64f12_t; -#else -} sim_cmtuartpad_strengh_t; -#endif - -/*! @brief SIM PTD7 pad drive strength */ -typedef enum _sim_ptd7pad_strengh -{ - kSimPtd7padSinglePad, /*!< Single-pad drive strength for PTD7 */ - kSimPtd7padDualPad /*!< Dual-pad drive strength for PTD7 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ptd7pad_strengh_k64f12_t; -#else -} sim_ptd7pad_strengh_t; -#endif - -/*! @brief SIM FlexBus security level */ -typedef enum _sim_flexbus_security_level -{ - kSimFbslLevel0, /*!< FlexBus security level 0. */ - kSimFbslLevel1, /*!< FlexBus security level 1. */ - kSimFbslLevel2, /*!< FlexBus security level 2. */ - kSimFbslLevel3, /*!< FlexBus security level 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_flexbus_security_level_k64f12_t; -#else -} sim_flexbus_security_level_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateI2c2 = FSL_SIM_SCGC_BIT(1U, 6U), - kSimClockGateUart4 = FSL_SIM_SCGC_BIT(1U, 10U), - kSimClockGateUart5 = FSL_SIM_SCGC_BIT(1U, 11U), - kSimClockGateEnet0 = FSL_SIM_SCGC_BIT(2U, 0U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(2U, 12U), - kSimClockGateDac1 = FSL_SIM_SCGC_BIT(2U, 13U), - kSimClockGateSpi2 = FSL_SIM_SCGC_BIT(3U, 12U), - kSimClockGateSdhc0 = FSL_SIM_SCGC_BIT(3U, 17U), - kSimClockGateFtm3 = FSL_SIM_SCGC_BIT(3U, 25U), - kSimClockGateAdc1 = FSL_SIM_SCGC_BIT(3U, 27U), - kSimClockGateEwm0 = FSL_SIM_SCGC_BIT(4U, 1U), - kSimClockGateCmt0 = FSL_SIM_SCGC_BIT(4U, 2U), - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUart3 = FSL_SIM_SCGC_BIT(4U, 13U), - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), - kSimClockGateCmp = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateFlexcan0 = FSL_SIM_SCGC_BIT(6U, 4U), - kSimClockGateRnga0 = FSL_SIM_SCGC_BIT(6U, 9U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(6U, 12U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(6U, 13U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), - kSimClockGateUsbdcd0 = FSL_SIM_SCGC_BIT(6U, 21U), - kSimClockGatePdb0 = FSL_SIM_SCGC_BIT(6U, 22U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateFtm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateFtm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateFtm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateFlexbus0 = FSL_SIM_SCGC_BIT(7U, 0U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 1U), - kSimClockGateMpu0 = FSL_SIM_SCGC_BIT(7U, 2U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_k64f12_t; -#else -} sim_clock_gate_name_t; -#endif - -/*@}*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetSdhcSrc(SIM_Type * base, - uint32_t instance, - clock_sdhc_src_t setting) -{ - SIM_BWR_SOPT2_SDHCSRC(base, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_HAL_GetSdhcSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_sdhc_src_t)SIM_BRD_SOPT2_SDHCSRC(base); -} - -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTimeSrc(SIM_Type * base, - uint32_t instance, - clock_time_src_t setting) -{ - SIM_BWR_SOPT2_TIMESRC(base, setting); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_time_src_t CLOCK_HAL_GetTimeSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_time_src_t)SIM_BRD_SOPT2_TIMESRC(base); -} - -/*! - * @brief Set the Ethernet RMII interface clock source selection. - * - * This function sets the Ethernet RMII interface clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRmiiSrc(SIM_Type * base, - uint32_t instance, - clock_rmii_src_t setting) -{ - SIM_BWR_SOPT2_RMIISRC(base, setting); -} - -/*! - * @brief Get the Ethernet RMII interface clock source selection. - * - * This function gets the Ethernet RMII interface clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_rmii_src_t CLOCK_HAL_GetRmiiSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_rmii_src_t)SIM_BRD_SOPT2_RMIISRC(base); -} - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac); - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac); - - -/*! - * @brief Set debug trace clock selection. - * - * This function sets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTraceClkSrc(SIM_Type * base, clock_trace_src_t setting) -{ - SIM_BWR_SOPT2_TRACECLKSEL(base, setting); -} - -/*! - * @brief Get debug trace clock selection. - * - * This function gets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_trace_src_t CLOCK_HAL_GetTraceClkSrc(SIM_Type * base) -{ - return (clock_trace_src_t)SIM_BRD_SOPT2_TRACECLKSEL(base); -} - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV2. - * - * This function sets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv2(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV2(base, setting); -} - -/*! - * @brief Get OUTDIV2. - * - * This function gets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv2(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV2(base); -} - -/*! - * @brief Set OUTDIV3. - * - * This function sets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv3(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV3(base, setting); -} - -/*! - * @brief Get OUTDIV3. - * - * This function gets divide value OUTDIV3. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv3(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV3(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); -/*! - * @brief Gets RAM size. - * - * This function gets the RAM size. The field specifies the amount of system RAM - * available on the device. - * - * @param base Base address for current SIM instance. - * @return size RAM size on the device - */ -static inline uint32_t SIM_HAL_GetRamSize(SIM_Type * base) -{ - return SIM_BRD_SOPT1_RAMSIZE(base); -} - -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} - -/*! - * @brief Sets the PTD7 pad drive strength setting. - * - * This function controls the output drive strength of the PTD7 pin by selecting - * either one or two pads to drive it. - * - * @param base Base address for current SIM instance. - * @param setting PTD7 pad drive strength setting - * - 0: Single-pad drive strength for PTD7. - * - 1: Double pad drive strength for PTD7. - */ -static inline void SIM_HAL_SetPtd7PadDriveStrengthMode(SIM_Type * base, - sim_ptd7pad_strengh_t setting) -{ - SIM_BWR_SOPT2_PTD7PAD(base, setting); -} - -/*! - * @brief Gets the PTD7 pad drive strength setting. - * - * This function gets the PTD7 pad drive strength setting. - * - * @param base Base address for current SIM instance. - * @return setting PTD7 pad drive strength setting - */ -static inline sim_ptd7pad_strengh_t SIM_HAL_GetPtd7PadDriveStrengthMode(SIM_Type * base) -{ - return (sim_ptd7pad_strengh_t)SIM_BRD_SOPT2_PTD7PAD(base); -} - -/*! - * @brief Sets the FlexBus security level setting. - * - * This function sets the FlexBus security level setting. If the security is enabled, - * this field affects which CPU operations can access the off-chip via the FlexBus - * and DDR controller interfaces. This field has no effect if the security is not enabled. - * - * @param base Base address for current SIM instance. - * @param setting FlexBus security level setting - * - 00: All off-chip accesses (op code and data) via the FlexBus and - * DDR controller are disallowed. - * - 10: Off-chip op code accesses are disallowed. Data accesses are - * allowed. - * - 11: Off-chip op code accesses and data accesses are allowed. - */ -static inline void SIM_HAL_SetFlexbusSecurityLevelMode(SIM_Type * base, - sim_flexbus_security_level_t setting) -{ - SIM_BWR_SOPT2_FBSL(base, setting); -} - -/*! - * @brief Gets the FlexBus security level setting. - * - * This function gets the FlexBus security level setting. - * - * @param base Base address for current SIM instance. - * @return setting FlexBus security level setting - */ -static inline sim_flexbus_security_level_t SIM_HAL_GetFlexbusSecurityLevelMode(SIM_Type * base) -{ - return (sim_flexbus_security_level_t)SIM_BRD_SOPT2_FBSL(base); -} - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select); - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select); - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the FlexTimer x hardware trigger y source select setting. - * - * This function selects the source of FTMx hardware trigger y. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @param select FlexTimer x hardware trigger y - * - 0: Pre-trigger A selected for ADCx. - * - 1: Pre-trigger B selected for ADCx. - */ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select); - -/*! - * @brief Gets the FlexTimer x hardware trigger y source select setting. - * - * This function gets the FlexTimer x hardware trigger y source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @return select FlexTimer x hardware trigger y source select setting - */ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger); - -/*! - * @brief Sets the FlexTimer x external clock pin select setting. - * - * This function selects the source of FTMx external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select FTMx external clock pin select - * - 0: FTMx external clock driven by FTM CLKIN0 pin. - * - 1: FTMx external clock driven by FTM CLKIN1 pin. - */ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select); - -/*! - * @brief Gets the FlexTimer x external clock pin select setting. - * - * This function gets the FlexTimer x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select FlexTimer x external clock pin select setting - */ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the FlexTimer x channel y input capture source select setting. - * - * This function selects the FlexTimer x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y input capture source - */ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y input capture source select setting. - * - * This function gets the FlexTimer x channel y input capture - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y input capture source select setting - */ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Sets the FlexTimer x fault y select setting. - * - * This function sets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @param select FlexTimer x fault y select setting - * - 0: FlexTimer x fault y select 0. - * - 1: FlexTimer x fault y select 1. - */ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select); - -/*! - * @brief Gets the FlexTimer x fault y select setting. - * - * This function gets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @return select FlexTimer x fault y select setting - */ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault); - -/*! - * @brief Gets the Kinetis Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Family ID in the System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Family ID - */ -static inline uint32_t SIM_HAL_GetFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMILYID(base); -} - -/*! - * @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Sub-Family ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Sub-Family ID - */ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} - -/*! - * @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Series ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Series ID - */ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type * base) -{ - return SIM_BRD_SDID_SERIESID(base); -} - -/*! - * @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Fam ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Fam ID - */ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the Kinetis Die ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Die ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Die ID - */ -static inline uint32_t SIM_HAL_GetDieId(SIM_Type * base) -{ - return SIM_BRD_SDID_DIEID(base); -} - -/*! - * @brief Gets the FlexNVM size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size FlexNVM Size - */ -static inline uint32_t SIM_HAL_GetFlexnvmSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_NVMSIZE(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Gets the EEProm size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the EEProm size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size EEProm Size - */ -static inline uint32_t SIM_HAL_GetEepromSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_EESIZE(base); -} - -/*! - * @brief Gets the FlexNVM partition in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM partition in the Flash Configuration Register1 - * - * @param base Base address for current SIM instance. - * @return setting FlexNVM partition setting - */ -static inline uint32_t SIM_HAL_GetFlexnvmPartition(SIM_Type * base) -{ - return SIM_BRD_FCFG1_DEPART(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -/*! - * @brief Gets the program flash in the Flash Configuration Register 2. - * - * This function gets the program flash maximum block 0 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return status program flash status - */ -static inline uint32_t SIM_HAL_GetProgramFlashCmd(SIM_Type * base) -{ - return SIM_BRD_FCFG2_PFLSH(base); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_SIM_HAL_K64F12_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MK65F18/fsl_sim_hal_MK65F18.c b/KSDK_1.2.0/platform/hal/src/sim/MK65F18/fsl_sim_hal_MK65F18.c deleted file mode 100755 index 0412fe2..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MK65F18/fsl_sim_hal_MK65F18.c +++ /dev/null @@ -1,1037 +0,0 @@ -/* - * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfsDiv - * Description : Gets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetPllFllDiv - * Description : Sets PLL/FLL divider setting. - * Divider output clock = Divider input clock * [ (PLLFLLFRAC+1) / (PLLFLLDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetPllFllDiv(SIM_Type * base, - uint8_t pllflldiv, - uint8_t pllfllfrac) -{ - SIM_BWR_CLKDIV3_PLLFLLDIV(base, pllflldiv); - SIM_BWR_CLKDIV3_PLLFLLFRAC(base, pllfllfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetPllFllDiv - * Description : Get PLL/FLL divider setting. - * Divider output clock = Divider input clock * [ (PLLFLLFRAC+1) / (PLLFLLDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetPllFllDiv(SIM_Type * base, - uint8_t *pllflldiv, - uint8_t *pllfllfrac) -{ - *pllflldiv = SIM_BRD_CLKDIV3_PLLFLLDIV(base); - *pllfllfrac = SIM_BRD_CLKDIV3_PLLFLLFRAC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetTraceDiv - * Description : Sets TRACECLK divider setting. - * Divider output clock = Divider input clock * [ (TRACEFRAC+1) / (TRACEDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetTraceDiv(SIM_Type * base, - uint8_t tracediv, - uint8_t tracefrac) -{ - SIM_BWR_CLKDIV4_TRACEDIV(base, tracediv); - SIM_BWR_CLKDIV4_TRACEFRAC(base, tracefrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetTraceDiv - * Description : Get TRACECLK divider setting. - * Divider output clock = Divider input clock * [ (TRACEFRAC+1) / (TRACEDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetTraceDiv(SIM_Type * base, - uint8_t *tracediv, - uint8_t *tracefrac) -{ - *tracediv = SIM_BRD_CLKDIV4_TRACEDIV(base); - *tracefrac = SIM_BRD_CLKDIV4_TRACEFRAC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV3(outdiv3); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = SIM_BRD_CLKDIV1_OUTDIV3(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - case 3: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM3TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM3TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - case 3: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM3TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM3TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - case 3: - SIM_BWR_SOPT4_FTM3CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - case 3: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM3CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM2CH1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - case 1: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/* Macro for FTMxOCHySRC. */ -#define FTM_CH_OUT_SRC_MASK(instance, channel) \ - (1U << ((((instance)>>1U)*8U) + channel + 16U)) - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChOutSrcMode - * Description : FlexTimer x channel y output source select setting. - * This function will select FlexTimer x channel y output source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_out_src_t select) -{ - assert ((0U==instance) || (3U==instance)); - assert (8U>channel); - - if (kSimFtmChOutSrc0 == select) - { - SIM_CLR_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } - else - { - SIM_SET_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChOutSrcMode - * Description : Get FlexTimer x channel y output source select setting - * This function will get FlexTimer x channel y output source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_out_src_t SIM_HAL_GetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - assert ((0U==instance) || (3U==instance)); - assert (8U>channel); - return (sim_ftm_ch_out_src_t) - (SIM_RD_SOPT8(base) & FTM_CH_OUT_SRC_MASK(instance, channel)); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmSyncCmd - * Description : Set FTMxSYNCBIT - * This function sets FlexTimer x hardware trigger 0 software synchronization. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmSyncCmd(SIM_Type * base, uint32_t instance, bool sync) -{ - assert (instance < FTM_INSTANCE_COUNT); - if (sync) - { - SIM_SET_SOPT8(base, (1U< -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type * base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfsDiv - * Description : Gets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type * base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetPllFllDiv - * Description : Sets PLL/FLL divider setting. - * Divider output clock = Divider input clock * [ (PLLFLLFRAC+1) / (PLLFLLDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetPllFllDiv(SIM_Type * base, - uint8_t pllflldiv, - uint8_t pllfllfrac) -{ - SIM_BWR_CLKDIV3_PLLFLLDIV(base, pllflldiv); - SIM_BWR_CLKDIV3_PLLFLLFRAC(base, pllfllfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetPllFllDiv - * Description : Get PLL/FLL divider setting. - * Divider output clock = Divider input clock * [ (PLLFLLFRAC+1) / (PLLFLLDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetPllFllDiv(SIM_Type * base, - uint8_t *pllflldiv, - uint8_t *pllfllfrac) -{ - *pllflldiv = SIM_BRD_CLKDIV3_PLLFLLDIV(base); - *pllfllfrac = SIM_BRD_CLKDIV3_PLLFLLFRAC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetTraceDiv - * Description : Sets TRACECLK divider setting. - * Divider output clock = Divider input clock * [ (TRACEFRAC+1) / (TRACEDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetTraceDiv(SIM_Type * base, - uint8_t tracediv, - uint8_t tracefrac) -{ - SIM_BWR_CLKDIV4_TRACEDIV(base, tracediv); - SIM_BWR_CLKDIV4_TRACEFRAC(base, tracefrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetTraceDiv - * Description : Get TRACECLK divider setting. - * Divider output clock = Divider input clock * [ (TRACEFRAC+1) / (TRACEDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetTraceDiv(SIM_Type * base, - uint8_t *tracediv, - uint8_t *tracefrac) -{ - *tracediv = SIM_BRD_CLKDIV4_TRACEDIV(base); - *tracefrac = SIM_BRD_CLKDIV4_TRACEFRAC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV3(outdiv3); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = SIM_BRD_CLKDIV1_OUTDIV3(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - case 3: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM3TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM3TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - case 3: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM3TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM3TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - case 3: - SIM_BWR_SOPT4_FTM3CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - case 3: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM3CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM2CH1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - case 1: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/* Macro for FTMxOCHySRC. */ -#define FTM_CH_OUT_SRC_MASK(instance, channel) \ - (1U << ((((instance)>>1U)*8U) + channel + 16U)) - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChOutSrcMode - * Description : FlexTimer x channel y output source select setting. - * This function will select FlexTimer x channel y output source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_out_src_t select) -{ - assert ((0U==instance) || (3U==instance)); - assert (8U>channel); - - if (kSimFtmChOutSrc0 == select) - { - SIM_CLR_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } - else - { - SIM_SET_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChOutSrcMode - * Description : Get FlexTimer x channel y output source select setting - * This function will get FlexTimer x channel y output source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_out_src_t SIM_HAL_GetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - assert ((0U==instance) || (3U==instance)); - assert (8U>channel); - return (sim_ftm_ch_out_src_t) - (SIM_RD_SOPT8(base) & FTM_CH_OUT_SRC_MASK(instance, channel)); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmSyncCmd - * Description : Set FTMxSYNCBIT - * This function sets FlexTimer x hardware trigger 0 software synchronization. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmSyncCmd(SIM_Type * base, uint32_t instance, bool sync) -{ - assert (instance < FTM_INSTANCE_COUNT); - if (sync) - { - SIM_SET_SOPT8(base, (1U< -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = 0U; - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable settingg - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, uint32_t instance, sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue =(sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - - if (altTrigEn) - { - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - } -} - - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmExternalClkPinSelMode - * Description : Set Timer/PWM x external clock pin select setting - * This function will select the source of Timer/PWM x external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_TPM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_TPM1CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetTpmExternalClkPinSelMode - * Description : Get Timer/PWM x external clock pin select setting - * This function will get Timer/PWM x external clock pin select setting. - * - *END**************************************************************************/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance) -{ - sim_tpm_clk_sel_t retValue = (sim_tpm_clk_sel_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM0CLKSEL(base); - break; - case 1: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM1CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmChSrcMode - * Description : Timer/PWM x channel y input capture source select setting - * This function will select Timer/PWM x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - SIM_BWR_SOPT4_TPM1CH0SRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetTpmChSrcMode - * Description : Get Timer/PWM x channel y input capture source select setting - * This function will get Timer/PWM x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_tpm_ch_src_t retValue = (sim_tpm_ch_src_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM1CH0SRC(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL02Z4/fsl_sim_hal_MKL02Z4.h b/KSDK_1.2.0/platform/hal/src/sim/MKL02Z4/fsl_sim_hal_MKL02Z4.h deleted file mode 100644 index 2c50aee..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL02Z4/fsl_sim_hal_MKL02Z4.h +++ /dev/null @@ -1,842 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_KL02Z4_H__) -#define __FSL_SIM_HAL_KL02Z4_H__ - -/*! - * @addtogroup sim_hal_kl02z4 - * @{ - */ -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - - /*! @brief COP clock source select */ -typedef enum _clock_cop_src_t -{ - kClockCopSrcLpoClk, /*!< LPO */ - kClockCopSrcAltClk, /*!< Alternative clock, for KL02Z4 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_cop_src_kl02z4_t; -#else -} clock_cop_src_t; -#endif - -/*! @brief TPM clock source select */ -typedef enum _clock_tpm_src -{ - kClockTpmSrcNone, /*!< clock disabled */ - kClockTpmSrcFll, /*!< MCGFLLCLK. */ - kClockTpmSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTpmSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tpm_src_kl02z4_t; -#else -} clock_tpm_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG out clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk, /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_kl02z4_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief UART0 clock source select */ -typedef enum _clock_lpsci_src -{ - kClockLpsciSrcNone, /*!< clock disabled */ - kClockLpsciSrcFll, /*!< MCGFLLCLK. */ - kClockLpsciSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockLpsciSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lpsci_src_kl02z4_t; -#else -} clock_lpsci_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutReserved = 0U, /*!< Reserved */ - kClockClkoutReserved1 = 1U, /*!< Reserved */ - kClockClkoutBusClk = 2U, /*!< Bus clock */ - kClockClkoutLpoClk = 3U, /*!< LPO clock */ - kClockClkoutMcgIrClk = 4U, /*!< MCG ir clock */ - kClockClkoutReserved2 = 5U, /*!< Reserved */ - kClockClkoutOsc0erClk = 6U, /*!< OSC0ER clock */ - kClockClkoutReserved3 = 7U /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_kl02z4_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_kl02z4_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelComp0 = 1U, /*!< CMP0 output */ - kSimAdcTrgSelReserved2 = 2U, /*!< Reserved */ - kSimAdcTrgSelReserved3 = 3U, /*!< Reserved */ - kSimAdcTrgSelReserved4 = 4U, /*!< Reserved */ - kSimAdcTrgSelReserved5 = 5U, /*!< Reserved */ - kSimAdcTrgSelReserved6 = 6U, /*!< Reserved */ - kSimAdcTrgSelReserved7 = 7U, /*!< Reserved */ - kSimAdcTrgSelTpm0 = 8U, /*!< TPM0 overflow */ - kSimAdcTrgSelTpm1 = 9U, /*!< TPM1 overflow */ - kSimAdcTrgSelReserved10 = 10U, /*!< Reserved */ - kSimAdcTrgSelReserved11 = 11U, /*!< Reserved */ - kSimAdcTrgSelReserved12 = 12U, /*!< Reserved */ - kSimAdcTrgSelReserved13 = 13U, /*!< Reserved */ - kSimAdcTrgSelLptimer = 14U, /*!< Low-power timer trigger */ - kSimAdcTrgSelReserved15 = 15U /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_kl02z4_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM LPSCI receive data source select */ -typedef enum _sim_lpsci_rxsrc -{ - kSimLpsciRxsrcPin, /*!< LPSCIx_RX Pin */ - kSimLpsciRxsrcCmp0, /*!< CMP0 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpsci_rxsrc_kl02z4_t; -#else -} sim_lpsci_rxsrc_t; -#endif - -/*! @brief SIM LPSCI transmit data source select */ -typedef enum _sim_lpsci_txsrc -{ - kSimLpsciTxsrcPin, /*!< LPSCIx_TX Pin */ - kSimLpsciTxsrcTpm1 /*!< LPSCIx_TX pin modulated with TPM1 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpsci_txsrc_kl02z4_t; -#else -} sim_lpsci_txsrc_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_kl02z4_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1 /*!< CMP0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_kl02z4_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateLpsci0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateCmp0 = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(4U, 22U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateTpm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateTpm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U) -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_kl02z4_t; -#else -} sim_clock_gate_name_t; -#endif - -/*@}*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTpmSrc(SIM_Type * base, - uint32_t instance, - clock_tpm_src_t setting) -{ - SIM_BWR_SOPT2_TPMSRC(base, setting); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_HAL_GetTpmSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_tpm_src_t)SIM_BRD_SOPT2_TPMSRC(base); -} - -/*! - * @brief Set the LPSCI clock source selection. - * - * This function sets the LPSCI clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetLpsciSrc(SIM_Type * base, - uint32_t instance, - clock_lpsci_src_t setting) -{ - SIM_BWR_SOPT2_UART0SRC(base, setting); -} - -/*! - * @brief Get the LPSCI clock source selection. - * - * This function gets the LPSCI clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_lpsci_src_t CLOCK_HAL_GetLpsciSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_lpsci_src_t)SIM_BRD_SOPT2_UART0SRC(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the LPSCIx receive data source select setting. - * - * This function selects the source for the LPSCIx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the LPSCIx receive data - */ -static inline void SIM_HAL_SetLpsciRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpsci_rxsrc_t select) -{ - SIM_BWR_SOPT5_UART0RXSRC(base, select); -} - -/*! - * @brief Gets the LPSCIx receive data source select setting. - * - * This function gets the LPSCIx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select LPSCIx receive data source select setting - */ -static inline sim_lpsci_rxsrc_t SIM_HAL_GetLpsciRxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_lpsci_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); -} - -/*! - * @brief Sets the LPSCIx transmit data source select setting. - * - * This function selects the source for the LPSCIx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the LPSCIx transmit data - */ -static inline void SIM_HAL_SetLpsciTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpsci_txsrc_t select) -{ - SIM_BWR_SOPT5_UART0TXSRC(base, select); -} - -/*! - * @brief Gets the LPSCIx transmit data source select setting. - * - * This function gets the LPSCIx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select LPSCIx transmit data source select setting - */ -static inline sim_lpsci_txsrc_t SIM_HAL_GetLpsciTxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_lpsci_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); -} - -#if FSL_FEATURE_SIM_OPT_HAS_ODE -/*! -* @brief Sets the LPSCIx Open Drain Enable setting. -* -* This function enables/disables the LPSCIx Open Drain. -* -* @param base Register base address of SIM. -* @param instance LPSCI instance. -* @param enable Enable/disable LPSCIx Open Drain -* - True: Enable LPSCIx Open Drain -* - False: Disable LPSCIx Open Drain -*/ -static inline void SIM_HAL_SetLpsciOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - SIM_BWR_SOPT5_UART0ODE(base, enable); -} - -/*! -* @brief Gets the LPSCIx Open Drain Enable setting. -* -* This function gets the LPSCIx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance LPSCI instance. -* @return enabled True if LPSCIx Open Drain is enabled. -*/ -static inline bool SIM_HAL_GetLpsciOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - return (bool)SIM_BRD_SOPT5_UART0ODE(base); -} -#endif - -#if FSL_FEATURE_SIM_OPT_HAS_TPM -/*! -* @brief Sets the Timer/PWM x external clock pin select setting. -* -* This function selects the source of the Timer/PWM x external clock pin select. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select Timer/PWM x external clock pin select -*/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select); - -/*! -* @brief Gets the Timer/PWM x external clock pin select setting. -* -* This function gets the Timer/PWM x external clock pin select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return Timer/PWM x external clock pin select setting -*/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the Timer/PWM x channel y input capture source select setting. -* -* This function selects the Timer/PWM x channel y input capture source. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @param select Timer/PWM x channel y input capture source -*/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select); - -/*! -* @brief Gets the Timer/PWM x channel y input capture source select setting. -* -* This function gets the Timer/PWM x channel y input capture source. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @return select Timer/PWM x channel y input capture source -*/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); -#endif - -/*! - * @brief Gets the Kinetis Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Family ID in the System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Family ID - */ -static inline uint32_t SIM_HAL_GetFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Sub-Family ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Sub-Family ID - */ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} - -/*! - * @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Series ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Series ID - */ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type * base) -{ - return SIM_BRD_SDID_SERIESID(base); -} - -/*! - * @brief Gets the Kinetis SramSize in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis SramSize in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis SramSize - */ -static inline uint32_t SIM_HAL_GetSramSize(SIM_Type * base) -{ - return SIM_BRD_SDID_SRAMSIZE(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the Kinetis Die ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Die ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Die ID - */ -static inline uint32_t SIM_HAL_GetDieId(SIM_Type * base) -{ - return SIM_BRD_SDID_DIEID(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_SIM_HAL_KL02Z4_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL03Z4/fsl_sim_hal_MKL03Z4.c b/KSDK_1.2.0/platform/hal/src/sim/MKL03Z4/fsl_sim_hal_MKL03Z4.c deleted file mode 100755 index cf13271..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL03Z4/fsl_sim_hal_MKL03Z4.c +++ /dev/null @@ -1,167 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* -* Definitions -******************************************************************************/ - -/******************************************************************************* -* APIs -******************************************************************************/ - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_HAL_SetOutDiv -* Description : Set all clock out dividers setting at the same time -* This function will set the setting for all clock out dividers. -* -*END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = 0U; - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetAdcTriggerModeOneStep -* Description : Set ADCx trigger setting. -* This function sets ADC alternate trigger, pre-trigger mode and trigger mode. -* -*END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - - if (altTrigEn) - { - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - } - -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetTpmExternalClkPinSelMode -* Description : Set Timer/PWM x external clock pin select setting -* This function will select the source of Timer/PWM x external clock pin select -* -*END**************************************************************************/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_TPM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_TPM1CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_GetTpmExternalClkPinSelMode -* Description : Get Timer/PWM x external clock pin select setting -* This function will get Timer/PWM x external clock pin select setting. -* -*END**************************************************************************/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance) -{ - sim_tpm_clk_sel_t retValue = (sim_tpm_clk_sel_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM0CLKSEL(base); - break; - case 1: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM1CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* -* EOF -******************************************************************************/ diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL03Z4/fsl_sim_hal_MKL03Z4.h b/KSDK_1.2.0/platform/hal/src/sim/MKL03Z4/fsl_sim_hal_MKL03Z4.h deleted file mode 100644 index 62552e7..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL03Z4/fsl_sim_hal_MKL03Z4.h +++ /dev/null @@ -1,1062 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#if !defined(__FSL_SIM_HAL_KL03Z4_H__) -#define __FSL_SIM_HAL_KL03Z4_H__ - -/*! - * @addtogroup sim_hal_kl03z4 - * @{ - */ -/*! @file*/ - -/******************************************************************************* -* Definitions -******************************************************************************/ -/*! @brief COP clock source selection.*/ -typedef enum _clock_cop_src { - kClockCopSrcLpoClk, /*!< LPO clock,1K HZ.*/ - kClockCopSrcMcgIrClk, /*!< MCG IRC Clock */ - kClockCopSrcOsc0erClk, /*!< OSCER Clock */ - kClockCopSrcBusClk /*!< BUS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -}clock_cop_src_kl03z4_t; -#else -}clock_cop_src_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U, /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_kl03z4_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM external reference clock output pin select (OSC32KOUT). */ -typedef enum _clock_osc32kout_sel -{ - kClockOsc32koutNone, /*!< ERCLK32K is not output. */ - kClockOsc32koutPtb13, /*!< ERCLK32K output on PTB13 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_osc32kout_sel_kl03z4_t; -#else -} clock_osc32kout_sel_t; -#endif - - -/*! @brief SIM LPUART0 clock source */ -typedef enum _clock_lpuart_src -{ - kClockLpuartSrcNone, /*!< disabled */ - kClockLpuartSrcIrc48M, /*!< IRC48M */ - kClockLpuartSrcOsc0erClk, /*!< OSCER clock */ - kClockLpuartSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lpuart_src_kl03z4_t; -#else -} clock_lpuart_src_t; -#endif - -/*! @brief SIM TPM clock source */ -typedef enum _clock_tpm_src -{ - kClockTpmSrcNone, /*!< disabled */ - kClockTpmSrcIrc48M, /*!< IRC48M */ - kClockTpmSrcOsc0erClk, /*!< OSCER clock */ - kClockTpmSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tpm_src_kl03z4_t; -#else -} clock_tpm_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG out clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk, /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_kl03z4_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCG out clock */ - kClockClkoutSelOsc0erClk = 6U, /*!< OSCER clock */ - kClockClkoutSelIrc48M = 7U /*!< IRC48M clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_kl03z4_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrcOsc0erClk, /*!< OSCER clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_kl03z4_t; -#else -} clock_rtcout_src_t; -#endif - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_kl03z4_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /*!< High speed comparator 0 output */ - kSimAdcTrgSelTpm0 = 8U, /*!< TPM0 trigger */ - kSimAdcTrgSelTpm1 = 9U, /*!< TPM1 trigger */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U, /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_kl03z4_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM LPUART receive data source select */ -typedef enum _sim_lpuart_rxsrc -{ - kSimLpuartRxsrcPin, /*!< LPUARTx_RX Pin */ - kSimLpuartRxsrcCmp0, /*!< CMP0 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpuart_rxsrc_kl03z4_t; -#else -} sim_lpuart_rxsrc_t; -#endif - -/*! @brief SIM LPUART transmit data source select */ -typedef enum _sim_lpuart_txsrc -{ - kSimLpuartTxsrcPin, /*!< LPUARTx_TX Pin */ - kSimLpuartTxsrcFtm1, /*!< LPUARTx_TX pin modulated with FTM1 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpuart_txsrc_kl03z4_t; -#else -} sim_lpuart_txsrc_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_kl03z4_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1 /*!< CMP0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_kl03z4_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM PTD7 pad drive strength */ -typedef enum _sim_ptd7pad_strengh -{ - kSimPtd7padSinglePad, /*!< Single-pad drive strength for PTD7 */ - kSimPtd7padDualPad /*!< Dual-pad drive strength for PTD7 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ptd7pad_strengh_kl03z4_t; -#else -} sim_ptd7pad_strengh_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateCmp0 = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(4U, 22U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGateLpuart0 = FSL_SIM_SCGC_BIT(5U, 20U), - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateTpm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateTpm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_kl03z4_t; -#else -} sim_clock_gate_name_t; -#endif - -/*@}*/ - -/******************************************************************************* -* API -******************************************************************************/ -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! -* @brief Disable the clock for specific module. -* -* This function disables the clock for specific module. -* -* @param base Base address for current SIM instance. -* @param name Name of the module to disable. -*/ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! -* @brief Get the the clock gate state for specific module. -* -* This function will get the clock gate state for specific module. -* -* @param base Base address for current SIM instance. -* @param name Name of the module to get. -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! -* @brief Set the clock selection of LPUART0. -* -* This function sets the clock selection of LPUART0. -* -* @param base Base address for current SIM instance. -* @param instance LPUART instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetLpuartSrc(SIM_Type * base, - uint32_t instance, - clock_lpuart_src_t setting) -{ - SIM_BWR_SOPT2_LPUART0SRC(base, setting); -} - -/*! -* @brief Get the clock selection of LPUART. -* -* This function gets the clock selection of LPUART. -* -* @param base Base address for current SIM instance. -* @param instance LPUART instance. -* @return Current selection. -*/ -static inline clock_lpuart_src_t CLOCK_HAL_GetLpuartSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_lpuart_src_t)SIM_BRD_SOPT2_LPUART0SRC(base); -} - -/*! -* @brief Set the clock selection of TPM. -* -* This function sets the clock selection of TPM. -* -* @param base Base address for current SIM instance. -* @param instance IP instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetTpmSrc(SIM_Type * base, - uint32_t instance, - clock_tpm_src_t setting) -{ - SIM_BWR_SOPT2_TPMSRC(base, setting); -} - -/*! -* @brief Get the clock selection of TPM. -* -* This function gets the clock selection of TPM. -* -* @param base Base address for current SIM instance. -* @param instance IP instance. -* @return Current selection. -*/ -static inline clock_tpm_src_t CLOCK_HAL_GetTpmSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_tpm_src_t)SIM_BRD_SOPT2_TPMSRC(base); -} - -/*! -* @brief Set the clock ERCLK32K output on selected pin. -* -* This function sets ERCLK32K output on selected pin. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetOsc32kOutSel(SIM_Type * base, - clock_osc32kout_sel_t setting) -{ - SIM_BWR_SOPT1_OSC32KOUT(base, setting); -} - -/*! -* @brief Get output status of ERCLK32K. -* -* This function gets the output status of ERCLK32K. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_osc32kout_sel_t CLOCK_HAL_GetOsc32kOutSel(SIM_Type * base) -{ - return (clock_osc32kout_sel_t)SIM_BRD_SOPT1_OSC32KOUT(base); -} - - -/*! -* @brief Set the clock selection of ERCLK32K. -* -* This function sets the clock selection of ERCLK32K. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! -* @brief Get the clock selection of ERCLK32K. -* -* This function gets the clock selection of ERCLK32K. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! -* @brief Set CLKOUTSEL selection. -* -* This function sets the selection of the clock to output on the CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! -* @brief Get CLKOUTSEL selection. -* -* This function gets the selection of the clock to output on the CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! -* @brief Set RTCCLKOUTSEL selection. -* -* This function sets the selection of the clock to output on the RTC_CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! -* @brief Get RTCCLKOUTSEL selection. -* -* This function gets the selection of the clock to output on the RTC_CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - - -/*! -* @brief Set the clock selection of COP. -* -* This function sets the clock selection of COP. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetCopSrc(SIM_Type * base, - clock_cop_src_t setting) -{ - SIM_BWR_COPC_COPCLKSEL(base, setting); -} - -/*! -* @brief Get the clock selection of COP. -* -* This function gets the clock selection of COP. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_cop_src_t CLOCK_HAL_GetCopSrc(SIM_Type * base) -{ - return (clock_cop_src_t)SIM_BRD_COPC_COPCLKSEL(base); -} - - -/*! -* @brief Set OUTDIV1. -* -* This function sets divide value OUTDIV1. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! -* @brief Get OUTDIV1. -* -* This function gets divide value OUTDIV1. -* -* @param base Base address for current SIM instance. -* @return Current divide value. -*/ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! -* @brief Set OUTDIV4. -* -* This function sets divide value OUTDIV4. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! -* @brief Get OUTDIV4. -* -* This function gets divide value OUTDIV4. -* -* @param base Base address for current SIM instance. -* @return Current divide value. -*/ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -/*! -* @brief Sets the ADCx alternate trigger enable setting. -* -* This function enables/disables the alternative conversion triggers for ADCx. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param enable Enable alternative conversion triggers for ADCx -* - true: Select alternative conversion trigger. -* - false: Select PDB trigger. -*/ -static inline void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - -} -/*! -* @brief Gets the ADCx alternate trigger enable setting. -* -* This function gets the ADCx alternate trigger enable setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return enabled True if ADCx alternate trigger is enabled -*/ - -static inline bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - - return retValue; -} - - -/*! -* @brief Sets the ADCx pre-trigger select setting. -* -* This function selects the ADCx pre-trigger source when the alternative -* triggers are enabled through ADCxALTTRGEN. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select pre-trigger select setting for ADCx -*/ -static inline void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - -} -/*! -* @brief Gets the ADCx pre-trigger select setting. -* -* This function gets the ADCx pre-trigger select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return select ADCx pre-trigger select setting -*/ -static inline sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - - return retValue; -} - -/*! -* @brief Sets the ADCx trigger select setting. -* -* This function selects the ADCx trigger source when alternative triggers -* are enabled through ADCxALTTRGEN. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select trigger select setting for ADCx -*/ -static inline void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - -} - -/*! -* @brief Gets the ADCx trigger select setting. -* -* This function gets the ADCx trigger select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return ADCx trigger select setting -*/ -static inline sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - - return retValue; -} - -/*! -* @brief Sets the ADCx trigger select setting in one function. -* -* This function sets ADC alternate trigger, pre-trigger mode and trigger mode. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param altTrigEn Alternative trigger enable or not. -* @param preTrigSel Pre-trigger mode. -* @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! -* @brief Sets the LPUARTx receive data source select setting. -* -* This function selects the source for the LPUARTx receive data. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @param select the source for the LPUARTx receive data -* - 00: LPUARTx_RX pin. -* - 01: CMP0. -* - 11: Reserved. -*/ -static inline void SIM_HAL_SetLpuartRxSrcMode(SIM_Type * base, uint32_t instance, sim_lpuart_rxsrc_t select) -{ - SIM_BWR_SOPT5_LPUART0RXSRC(base, select); - -} - -/*! -* @brief Gets the LPUARTx receive data source select setting. -* -* This function gets the LPUARTx receive data source select setting. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* -* @return select UARTx receive data source select setting -*/ -static inline sim_lpuart_rxsrc_t SIM_HAL_GetLpuartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_lpuart_rxsrc_t retValue = (sim_lpuart_rxsrc_t)0; - - retValue = (sim_lpuart_rxsrc_t)SIM_BRD_SOPT5_LPUART0RXSRC(base); - - return retValue; -} - -/*! -* @brief Sets the LPUARTx transmit data source select setting. -* -* This function selects the source for the LPUARTx transmit data. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @param select the source for the UARTx transmit data -* - 00: LPUARTx_TX pin. -* - 01: LPUARTx_TX pin modulated with FTM1 channel 0 output. -* - 11: Reserved. -*/ -static inline void SIM_HAL_SetLpuartTxSrcMode(SIM_Type * base, uint32_t instance, sim_lpuart_txsrc_t select) -{ - SIM_BWR_SOPT5_LPUART0TXSRC(base, select); - -} - -/*! -* @brief Gets the LPUARTx transmit data source select setting. -* -* This function gets the LPUARTx transmit data source select setting. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @return select UARTx transmit data source select setting -*/ -static inline sim_lpuart_txsrc_t SIM_HAL_GetLpuartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_lpuart_txsrc_t retValue =(sim_lpuart_txsrc_t)0; - - retValue = (sim_lpuart_txsrc_t)SIM_BRD_SOPT5_LPUART0TXSRC(base); - - return retValue; -} - -/*! -* @brief Sets the LPUARTx Open Drain Enable setting. -* -* This function enables/disables the LPUARTx Open Drain. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @param enable Enable/disable LPUARTx Open Drain -* - True: Enable LPUARTx Open Drain -* - False: Disable LPUARTx Open Drain -*/ -static inline void SIM_HAL_SetLpuartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - SIM_BWR_SOPT5_LPUART0ODE(base, enable ? 1 : 0); - -} - -/*! -* @brief Gets the LPUARTx Open Drain Enable setting. -* -* This function gets the LPUARTx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @return enabled True if LPUARTx Open Drain is enabled. -*/ -static inline bool SIM_HAL_GetLpuartOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - retValue = SIM_BRD_SOPT5_LPUART0ODE(base); - - return retValue; -} - -/*! -* @brief Sets the Timer/PWM x channel y input capture source select setting. -* -* This function selects the Timer/PWM x channel y input capture source. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @param select Timer/PWM x channel y input capture source -*/ -static inline void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select) -{ - if(instance == 1) - { - SIM_BWR_SOPT4_TPM1CH0SRC(base, select); - } -} - -/*! -* @brief Gets the Timer/PWM x channel y input capture source select setting. -* -* This function gets the Timer/PWM x channel y input capture source select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel Tpm channel y -* @return select Timer/PWM x channel y input capture source select setting -*/ -static inline sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_tpm_ch_src_t retValue = (sim_tpm_ch_src_t)0; - - if(instance == 1) - { - - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM1CH0SRC(base); - } - - return retValue; -} - -/*! -* @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Sub-Family ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Sub-Family ID -*/ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} - -/*! -* @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Series ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Series ID -*/ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type * base) -{ - return SIM_BRD_SDID_SERIESID(base); -} - -/*! -* @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Fam ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Fam ID -*/ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! -* @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Pincount ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Pincount ID -*/ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! -* @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Revision ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Revision ID -*/ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! -* @brief Gets the Kinetis Die ID in the System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Die ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Die ID -*/ -static inline uint32_t SIM_HAL_GetDieId(SIM_Type * base) -{ - return SIM_BRD_SDID_DIEID(base); -} - -/*! -* @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function gets the program flash size in the Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @return size Program flash Size -*/ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! -* @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function sets the Flash Doze in the Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @param setting Flash Doze setting -*/ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! -* @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function gets the Flash Doze in the Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @return setting Flash Doze setting -*/ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! -* @brief Sets the Flash disable setting. -* -* This function sets the Flash disable setting in the -* Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @param disable Flash disable setting -*/ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! -* @brief Gets the Flash disable setting. -* -* This function gets the Flash disable setting in the -* Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @return setting Flash disable setting -*/ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! -* @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function gets the Flash maximum block 0 in Flash Configuration Register 2. -* -* @param base Base address for current SIM instance. -* @return address Flash maximum block 0 address -*/ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! -* @brief Sets the Timer/PWM x external clock pin select setting. -* -* This function selects the source of the Timer/PWM x external clock pin select. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select Timer/PWM x external clock pin select -* - 0: Timer/PWM x external clock driven by the TPM_CLKIN0 pin. -* - 1: Timer/PWM x external clock driven by the TPM_CLKIN1 pin. -*/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance, sim_tpm_clk_sel_t select); - -/*! -* @brief Gets the Timer/PWM x external clock pin select setting. -* -* This function gets the Timer/PWM x external clock pin select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return select Timer/PWM x external clock pin select setting -*/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance); - - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_SIM_HAL_KL03Z4_H__*/ -/******************************************************************************* -* EOF -******************************************************************************/ diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL14Z4/fsl_sim_hal_MKL14Z4.c b/KSDK_1.2.0/platform/hal/src/sim/MKL14Z4/fsl_sim_hal_MKL14Z4.c deleted file mode 100755 index 4598b07..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL14Z4/fsl_sim_hal_MKL14Z4.c +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = 0U; - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable settingg - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, uint32_t instance, sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue =(sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - - if (altTrigEn) - { - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartOpenDrainCmd - * Description : Set UARTx Open Drain Enable setting - * This function will enable/disable the UARTx Open Drain. - * - *END**************************************************************************/ -void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 1: - SIM_BWR_SOPT5_UART1ODE(base, enable ? 1 : 0); - break; - case 2: - SIM_BWR_SOPT5_UART2ODE(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartOpenDrainCmd - * Description : Get UARTx Open Drain Enable setting - * This function will get UARTx Open Drain Enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 1: - retValue = SIM_BRD_SOPT5_UART1ODE(base); - break; - case 2: - retValue = SIM_BRD_SOPT5_UART2ODE(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmExternalClkPinSelMode - * Description : Set Timer/PWM x external clock pin select setting - * This function will select the source of Timer/PWM x external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_TPM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_TPM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_TPM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetTpmExternalClkPinSelMode - * Description : Get Timer/PWM x external clock pin select setting - * This function will get Timer/PWM x external clock pin select setting. - * - *END**************************************************************************/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance) -{ - sim_tpm_clk_sel_t retValue = (sim_tpm_clk_sel_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM0CLKSEL(base); - break; - case 1: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM1CLKSEL(base); - break; - case 2: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmChSrcMode - * Description : Timer/PWM x channel y input capture source select setting - * This function will select Timer/PWM x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - SIM_BWR_SOPT4_TPM1CH0SRC(base, select); - break; - case 2: - SIM_BWR_SOPT4_TPM2CH0SRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetTpmChSrcMode - * Description : Get Timer/PWM x channel y input capture source select setting - * This function will get Timer/PWM x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_tpm_ch_src_t retValue = (sim_tpm_ch_src_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM1CH0SRC(base); - break; - case 2: - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM2CH0SRC(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL14Z4/fsl_sim_hal_MKL14Z4.h b/KSDK_1.2.0/platform/hal/src/sim/MKL14Z4/fsl_sim_hal_MKL14Z4.h deleted file mode 100644 index c986d8a..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL14Z4/fsl_sim_hal_MKL14Z4.h +++ /dev/null @@ -1,1298 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_KL14Z4_H__) -#define __FSL_SIM_HAL_KL14Z4_H__ - -/*! @addtogroup sim_hal*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - - /*! @brief COP clock source select */ -typedef enum _clock_cop_src_t -{ - kClockCopSrcLpoClk, /* LPO */ - kClockCopSrcAltClk, /* Altnative clock, for KL14Z4 it is Bus clock. */ -} clock_cop_src_t; - -/*! @brief TPM clock source select */ -typedef enum _clock_tpm_src -{ - kClockTpmSrcNone, /* clock disabled */ - kClockTpmSrcPllFllSel, /* clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTpmSrcOsc0erClk, /* OSCERCLK clock */ - kClockTpmSrcMcgIrClk /* MCGIR clock */ -} clock_tpm_src_t; - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /* MCG out clock */ - kClockLptmrSrcLpoClk, /* LPO clock */ - kClockLptmrSrcEr32kClk, /* ERCLK32K clock */ - kClockLptmrSrcOsc0erClk, /* OSCERCLK clock */ -} clock_lptmr_src_t; - -/*! @brief UART0 clock source select */ -typedef enum _clock_lpsci_src -{ - kClockLpsciSrcNone, /* clock disabled */ - kClockLpsciSrcPllFllSel, /* clock as selected by SOPT2[PLLFLLSEL]. */ - kClockLpsciSrcOsc0erClk, /* OSCERCLK clock */ - kClockLpsciSrcMcgIrClk /* MCGIR clock */ -} clock_lpsci_src_t; - -/*! @brief USB clock source select */ -#if FSL_FEATURE_SOC_USB_COUNT -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /* USB CLKIN Clock */ - kClockUsbfsSrcPllFllSel /* clock as selected by SOPT2[PLLFLLSEL] */ -} clock_usbfs_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll, /* Fll clock */ - kClockPllFllSelPll /* Pll0 clock */ -} clock_pllfll_sel_t; - -/*! @brief SIM external reference clock source select (OSC32KSEL) */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /* OSC 32k clock */ - kClockEr32kSrcReserved = 1U, /* Reserved */ - kClockEr32kSrcRtc = 2U, /* RTC 32k clock */ - kClockEr32kSrcLpo = 3U /* LPO clock */ -} clock_er32k_src_t; - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutReserved = 0U, /* Reserved */ - kClockClkoutReserved1 = 1U, /* Reserved */ - kClockClkoutBusClk = 2U, /* Bus clock */ - kClockClkoutLpoClk = 3U, /* LPO clock */ - kClockClkoutMcgIrClk = 4U, /* MCG ir clock */ - kClockClkoutReserved2 = 5U, /* Reserved */ - kClockClkoutOsc0erClk = 6U, /* OSC0ER clock */ - kClockClkoutReserved3 = 7U -} clock_clkout_src_t; - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /* 1Hz clock */ - kClockRtcoutSrc32kHz /* 32KHz clock */ -} clock_rtcout_src_t; - -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -#if FSL_FEATURE_SOC_USB_COUNT -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /* regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /* regulator in standby during Stop modes */ -} sim_usbsstby_mode_t; - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /* regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /* regulator in standby during VLPR and VLPW modes */ -} sim_usbvstby_mode_t; -#endif - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /* Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /* Pre-trigger B selected for ADCx */ -} sim_adc_pretrg_sel_t; - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /* External trigger */ - kSimAdcTrgSelComp0 = 1U, /* CMP0 output */ - kSimAdcTrgSelReserved = 2U, /* Reserved */ - kSimAdcTrgSelReserved1 = 3U, /* Reserved */ - kSimAdcTrgSelPit0 = 4U, /* PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /* PIT trigger 1 */ - kSimAdcTrgSelReserved2 = 6U, /* Reserved */ - kSimAdcTrgSelReserved3 = 7U, /* Reserved */ - kSimAdcTrgSelTpm0 = 8U, /* TPM0 overflow */ - kSimAdcTrgSelTpm1 = 9U, /* TPM1 overflow */ - kSimAdcTrgSelTpm2 = 10U, /* TPM2 overflow */ - kSimAdcTrgSelReserved4 = 11U, /* Reserved */ - kSimAdcTrgSelRtcAlarm = 12U, /* RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /* RTC seconds */ - kSimAdcTrgSelLptimer = 14U, /* Low-power timer trigger */ - kSimAdcTrgSelReserved5 = 15U /* Reserved */ -} sim_adc_trg_sel_t; - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /* UARTx_RX Pin */ - kSimUartRxsrcCmp0, /* CMP0 */ -} sim_uart_rxsrc_t; - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /* UARTx_TX Pin */ - kSimUartTxsrcTpm0, /* UARTx_TX pin modulated with TPM1 channel 0 output */ - kSimUartTxsrcTpm1, /* UARTx_TX pin modulated with TPM2 channel 0 output */ - kSimUartTxsrcReserved /* Reserved */ -} sim_uart_txsrc_t; - -/*! @brief SIM LPSCI receive data source select */ -typedef enum _sim_lpsci_rxsrc -{ - kSimLpsciRxsrcPin, /* LPSCIx_RX Pin */ - kSimLpsciRxsrcCmp0, /* CMP0 */ -} sim_lpsci_rxsrc_t; - -/*! @brief SIM LPSCI transmit data source select */ -typedef enum _sim_lpsci_txsrc -{ - kSimLpsciTxsrcPin, /* LPSCIx_TX Pin */ - kSimLpsciTxsrcTpm0, /* LPSCIx_TX pin modulated with TPM1 channel 0 output */ - kSimLpsciTxsrcTpm1, /* LPSCIx_TX pin modulated with TPM2 channel 0 output */ - kSimLpsciTxsrcReserved /* Reserved */ -} sim_lpsci_txsrc_t; - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /* Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /* Timer/PWM TPM_CLKIN1 pin. */ -} sim_tpm_clk_sel_t; - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /* TPMx_CH0 signal */ - kSimTpmChSrc1, /* CMP0 output */ - kSimTpmChSrc2, /* Reserved */ - kSimTpmChSrc3 /* USB start of frame pulse */ -} sim_tpm_ch_src_t; - -/* SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -typedef enum _sim_clock_gate_name -{ - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateLpsci0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), - kSimClockGateCmp0 = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(4U, 22U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(4U, 23U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGateTsi0 = FSL_SIM_SCGC_BIT(5U, 5U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateTpm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateTpm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateTpm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(6U, 31U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 8U) -} sim_clock_gate_name_t; - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! @name IP related clock feature APIs*/ -/*@{*/ - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ - #if FSL_FEATURE_SOC_USB_COUNT -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} -#endif - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTpmSrc(SIM_Type * base, - uint32_t instance, - clock_tpm_src_t setting) -{ - SIM_BWR_SOPT2_TPMSRC(base, setting); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_HAL_GetTpmSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_tpm_src_t)SIM_BRD_SOPT2_TPMSRC(base); -} - -/*! - * @brief Set the LPSCI clock source selection. - * - * This function sets the LPSCI clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetLpsciSrc(SIM_Type * base, - uint32_t instance, - clock_lpsci_src_t setting) -{ - SIM_BWR_SOPT2_UART0SRC(base, setting); -} - -/*! - * @brief Get the LPSCI clock source selection. - * - * This function gets the LPSCI clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_lpsci_src_t CLOCK_HAL_GetLpsciSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_lpsci_src_t)SIM_BRD_SOPT2_UART0SRC(base); -} -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - - * This function sets the setting for all clock out dividers at the same time. - - * - - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -#if FSL_FEATURE_SOC_USB_COUNT -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -static inline void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - SIM_BWR_SOPT5_UART1RXSRC(base, select); -} - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -static inline sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); -} - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -static inline void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - SIM_BWR_SOPT5_UART1TXSRC(base, select); -} - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -static inline sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); -} - -/*! - * @brief Sets the LPSCIx receive data source select setting. - * - * This function selects the source for the LPSCIx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the LPSCIx receive data - */ -static inline void SIM_HAL_SetLpsciRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpsci_rxsrc_t select) -{ - SIM_BWR_SOPT5_UART0RXSRC(base, select); -} - -/*! - * @brief Gets the LPSCIx receive data source select setting. - * - * This function gets the LPSCIx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select LPSCIx receive data source select setting - */ -static inline sim_lpsci_rxsrc_t SIM_HAL_GetLpsciRxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_lpsci_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); -} - -/*! - * @brief Sets the LPSCIx transmit data source select setting. - * - * This function selects the source for the LPSCIx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the LPSCIx transmit data - */ -static inline void SIM_HAL_SetLpsciTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpsci_txsrc_t select) -{ - SIM_BWR_SOPT5_UART0TXSRC(base, select); -} - -/*! - * @brief Gets the LPSCIx transmit data source select setting. - * - * This function gets the LPSCIx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select LPSCIx transmit data source select setting - */ -static inline sim_lpsci_txsrc_t SIM_HAL_GetLpsciTxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_lpsci_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); -} - -#if FSL_FEATURE_SIM_OPT_HAS_ODE - -/*! -* @brief Sets the UARTx Open Drain Enable setting. - - -* -* This function enables/disables the UARTx Open Drain. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @param enable Enable/disable UARTx Open Drain - - -* - True: Enable UARTx Open Drain -* - False: Disable UARTx Open Drain -*/ -void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable); - -/*! -* @brief Gets the UARTx Open Drain Enable setting. -* -* This function gets the UARTx Open Drain Enable setting. - - -* -* @param base Register base address of SIM. -* @param instance UART instance. -*/ -bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the LPSCIx Open Drain Enable setting. -* -* This function enables/disables the LPSCIx Open Drain. -* -* @param base Register base address of SIM. -* @param instance LPSCI instance. -* @param enable Enable/disable LPSCIx Open Drain -* - True: Enable LPSCIx Open Drain -* - False: Disable LPSCIx Open Drain -*/ -static inline void SIM_HAL_SetLpsciOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - SIM_BWR_SOPT5_UART0ODE(base, enable); -} - -/*! -* @brief Gets the LPSCIx Open Drain Enable setting. -* -* This function gets the LPSCIx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance LPSCI instance. -* @return enabled True if LPSCIx Open Drain is enabled. -*/ -static inline bool SIM_HAL_GetLpsciOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - return (bool)SIM_BRD_SOPT5_UART0ODE(base); -} -#endif - -#if FSL_FEATURE_SIM_OPT_HAS_TPM - -/*! -* @brief Sets the Timer/PWM x external clock pin select setting. -* -* This function selects the source of the Timer/PWM x external clock pin select. - - -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select Timer/PWM x external clock pin select -*/ - -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select); - -/*! -* @brief Gets the Timer/PWM x external clock pin select setting. -* -* This function gets the Timer/PWM x external clock pin select setting. - - -* -* @param base Base address for current SIM instance. -* @param instance device instance. -*/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the Timer/PWM x channel y input capture source select setting. -* -* This function selects the Timer/PWM x channel y input capture source. - - -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @param select Timer/PWM x channel y input capture source -*/ - -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select); - -/*! -* @brief Gets the Timer/PWM x channel y input capture source select setting. -* -* This function gets the Timer/PWM x channel y input capture source. - - -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -*/ - -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); -#endif - -/*! - * @brief Gets the Kinetis Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Family ID in the System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Family ID - */ -static inline uint32_t SIM_HAL_GetFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Sub-Family ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Sub-Family ID - */ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} - -/*! - * @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Series ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Series ID - */ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type * base) -{ - return SIM_BRD_SDID_SERIESID(base); -} - -/*! - * @brief Gets the Kinetis SramSize in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis SramSize in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis SramSize - */ -static inline uint32_t SIM_HAL_GetSramSize(SIM_Type * base) -{ - return SIM_BRD_SDID_SRAMSIZE(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the Kinetis Die ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Die ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Die ID - */ -static inline uint32_t SIM_HAL_GetDieId(SIM_Type * base) -{ - return SIM_BRD_SDID_DIEID(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_SIM_HAL_KL14Z4_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL15Z4/fsl_sim_hal_MKL15Z4.c b/KSDK_1.2.0/platform/hal/src/sim/MKL15Z4/fsl_sim_hal_MKL15Z4.c deleted file mode 100755 index 4598b07..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL15Z4/fsl_sim_hal_MKL15Z4.c +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = 0U; - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable settingg - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, uint32_t instance, sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue =(sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - - if (altTrigEn) - { - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartOpenDrainCmd - * Description : Set UARTx Open Drain Enable setting - * This function will enable/disable the UARTx Open Drain. - * - *END**************************************************************************/ -void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 1: - SIM_BWR_SOPT5_UART1ODE(base, enable ? 1 : 0); - break; - case 2: - SIM_BWR_SOPT5_UART2ODE(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartOpenDrainCmd - * Description : Get UARTx Open Drain Enable setting - * This function will get UARTx Open Drain Enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 1: - retValue = SIM_BRD_SOPT5_UART1ODE(base); - break; - case 2: - retValue = SIM_BRD_SOPT5_UART2ODE(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmExternalClkPinSelMode - * Description : Set Timer/PWM x external clock pin select setting - * This function will select the source of Timer/PWM x external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_TPM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_TPM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_TPM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetTpmExternalClkPinSelMode - * Description : Get Timer/PWM x external clock pin select setting - * This function will get Timer/PWM x external clock pin select setting. - * - *END**************************************************************************/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance) -{ - sim_tpm_clk_sel_t retValue = (sim_tpm_clk_sel_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM0CLKSEL(base); - break; - case 1: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM1CLKSEL(base); - break; - case 2: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmChSrcMode - * Description : Timer/PWM x channel y input capture source select setting - * This function will select Timer/PWM x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - SIM_BWR_SOPT4_TPM1CH0SRC(base, select); - break; - case 2: - SIM_BWR_SOPT4_TPM2CH0SRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetTpmChSrcMode - * Description : Get Timer/PWM x channel y input capture source select setting - * This function will get Timer/PWM x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_tpm_ch_src_t retValue = (sim_tpm_ch_src_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM1CH0SRC(base); - break; - case 2: - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM2CH0SRC(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL15Z4/fsl_sim_hal_MKL15Z4.h b/KSDK_1.2.0/platform/hal/src/sim/MKL15Z4/fsl_sim_hal_MKL15Z4.h deleted file mode 100644 index 897f4a0..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL15Z4/fsl_sim_hal_MKL15Z4.h +++ /dev/null @@ -1,1298 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_KL15Z4_H__) -#define __FSL_SIM_HAL_KL15Z4_H__ - -/*! @addtogroup sim_hal*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - - /*! @brief COP clock source select */ -typedef enum _clock_cop_src_t -{ - kClockCopSrcLpoClk, /* LPO */ - kClockCopSrcAltClk, /* Altnative clock, for KL15Z4 it is Bus clock. */ -} clock_cop_src_t; - -/*! @brief TPM clock source select */ -typedef enum _clock_tpm_src -{ - kClockTpmSrcNone, /* clock disabled */ - kClockTpmSrcPllFllSel, /* clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTpmSrcOsc0erClk, /* OSCERCLK clock */ - kClockTpmSrcMcgIrClk /* MCGIR clock */ -} clock_tpm_src_t; - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /* MCG out clock */ - kClockLptmrSrcLpoClk, /* LPO clock */ - kClockLptmrSrcEr32kClk, /* ERCLK32K clock */ - kClockLptmrSrcOsc0erClk, /* OSCERCLK clock */ -} clock_lptmr_src_t; - -/*! @brief UART0 clock source select */ -typedef enum _clock_lpsci_src -{ - kClockLpsciSrcNone, /* clock disabled */ - kClockLpsciSrcPllFllSel, /* clock as selected by SOPT2[PLLFLLSEL]. */ - kClockLpsciSrcOsc0erClk, /* OSCERCLK clock */ - kClockLpsciSrcMcgIrClk /* MCGIR clock */ -} clock_lpsci_src_t; - -/*! @brief USB clock source select */ -#if FSL_FEATURE_SOC_USB_COUNT -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /* USB CLKIN Clock */ - kClockUsbfsSrcPllFllSel /* clock as selected by SOPT2[PLLFLLSEL] */ -} clock_usbfs_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll, /* Fll clock */ - kClockPllFllSelPll /* Pll0 clock */ -} clock_pllfll_sel_t; - -/*! @brief SIM external reference clock source select (OSC32KSEL) */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /* OSC 32k clock */ - kClockEr32kSrcReserved = 1U, /* Reserved */ - kClockEr32kSrcRtc = 2U, /* RTC 32k clock */ - kClockEr32kSrcLpo = 3U /* LPO clock */ -} clock_er32k_src_t; - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutReserved = 0U, /* Reserved */ - kClockClkoutReserved1 = 1U, /* Reserved */ - kClockClkoutBusClk = 2U, /* Bus clock */ - kClockClkoutLpoClk = 3U, /* LPO clock */ - kClockClkoutMcgIrClk = 4U, /* MCG ir clock */ - kClockClkoutReserved2 = 5U, /* Reserved */ - kClockClkoutOsc0erClk = 6U, /* OSC0ER clock */ - kClockClkoutReserved3 = 7U -} clock_clkout_src_t; - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /* 1Hz clock */ - kClockRtcoutSrc32kHz /* 32KHz clock */ -} clock_rtcout_src_t; - -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -#if FSL_FEATURE_SOC_USB_COUNT -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /* regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /* regulator in standby during Stop modes */ -} sim_usbsstby_mode_t; - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /* regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /* regulator in standby during VLPR and VLPW modes */ -} sim_usbvstby_mode_t; -#endif - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /* Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /* Pre-trigger B selected for ADCx */ -} sim_adc_pretrg_sel_t; - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /* External trigger */ - kSimAdcTrgSelComp0 = 1U, /* CMP0 output */ - kSimAdcTrgSelReserved = 2U, /* Reserved */ - kSimAdcTrgSelReserved1 = 3U, /* Reserved */ - kSimAdcTrgSelPit0 = 4U, /* PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /* PIT trigger 1 */ - kSimAdcTrgSelReserved2 = 6U, /* Reserved */ - kSimAdcTrgSelReserved3 = 7U, /* Reserved */ - kSimAdcTrgSelTpm0 = 8U, /* TPM0 overflow */ - kSimAdcTrgSelTpm1 = 9U, /* TPM1 overflow */ - kSimAdcTrgSelTpm2 = 10U, /* TPM2 overflow */ - kSimAdcTrgSelReserved4 = 11U, /* Reserved */ - kSimAdcTrgSelRtcAlarm = 12U, /* RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /* RTC seconds */ - kSimAdcTrgSelLptimer = 14U, /* Low-power timer trigger */ - kSimAdcTrgSelReserved5 = 15U /* Reserved */ -} sim_adc_trg_sel_t; - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /* UARTx_RX Pin */ - kSimUartRxsrcCmp0, /* CMP0 */ -} sim_uart_rxsrc_t; - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /* UARTx_TX Pin */ - kSimUartTxsrcTpm0, /* UARTx_TX pin modulated with TPM1 channel 0 output */ - kSimUartTxsrcTpm1, /* UARTx_TX pin modulated with TPM2 channel 0 output */ - kSimUartTxsrcReserved /* Reserved */ -} sim_uart_txsrc_t; - -/*! @brief SIM LPSCI receive data source select */ -typedef enum _sim_lpsci_rxsrc -{ - kSimLpsciRxsrcPin, /* LPSCIx_RX Pin */ - kSimLpsciRxsrcCmp0, /* CMP0 */ -} sim_lpsci_rxsrc_t; - -/*! @brief SIM LPSCI transmit data source select */ -typedef enum _sim_lpsci_txsrc -{ - kSimLpsciTxsrcPin, /* LPSCIx_TX Pin */ - kSimLpsciTxsrcTpm0, /* LPSCIx_TX pin modulated with TPM1 channel 0 output */ - kSimLpsciTxsrcTpm1, /* LPSCIx_TX pin modulated with TPM2 channel 0 output */ - kSimLpsciTxsrcReserved /* Reserved */ -} sim_lpsci_txsrc_t; - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /* Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /* Timer/PWM TPM_CLKIN1 pin. */ -} sim_tpm_clk_sel_t; - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /* TPMx_CH0 signal */ - kSimTpmChSrc1, /* CMP0 output */ - kSimTpmChSrc2, /* Reserved */ - kSimTpmChSrc3 /* USB start of frame pulse */ -} sim_tpm_ch_src_t; - -/* SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -typedef enum _sim_clock_gate_name -{ - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateLpsci0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), - kSimClockGateCmp0 = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(4U, 22U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(4U, 23U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGateTsi0 = FSL_SIM_SCGC_BIT(5U, 5U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateTpm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateTpm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateTpm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(6U, 31U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 8U) -} sim_clock_gate_name_t; - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! @name IP related clock feature APIs*/ -/*@{*/ - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ - #if FSL_FEATURE_SOC_USB_COUNT -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} -#endif - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTpmSrc(SIM_Type * base, - uint32_t instance, - clock_tpm_src_t setting) -{ - SIM_BWR_SOPT2_TPMSRC(base, setting); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_HAL_GetTpmSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_tpm_src_t)SIM_BRD_SOPT2_TPMSRC(base); -} - -/*! - * @brief Set the LPSCI clock source selection. - * - * This function sets the LPSCI clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetLpsciSrc(SIM_Type * base, - uint32_t instance, - clock_lpsci_src_t setting) -{ - SIM_BWR_SOPT2_UART0SRC(base, setting); -} - -/*! - * @brief Get the LPSCI clock source selection. - * - * This function gets the LPSCI clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_lpsci_src_t CLOCK_HAL_GetLpsciSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_lpsci_src_t)SIM_BRD_SOPT2_UART0SRC(base); -} -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - - * This function sets the setting for all clock out dividers at the same time. - - * - - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -#if FSL_FEATURE_SOC_USB_COUNT -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -static inline void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - SIM_BWR_SOPT5_UART1RXSRC(base, select); -} - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -static inline sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); -} - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -static inline void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - SIM_BWR_SOPT5_UART1TXSRC(base, select); -} - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -static inline sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); -} - -/*! - * @brief Sets the LPSCIx receive data source select setting. - * - * This function selects the source for the LPSCIx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the LPSCIx receive data - */ -static inline void SIM_HAL_SetLpsciRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpsci_rxsrc_t select) -{ - SIM_BWR_SOPT5_UART0RXSRC(base, select); -} - -/*! - * @brief Gets the LPSCIx receive data source select setting. - * - * This function gets the LPSCIx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select LPSCIx receive data source select setting - */ -static inline sim_lpsci_rxsrc_t SIM_HAL_GetLpsciRxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_lpsci_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); -} - -/*! - * @brief Sets the LPSCIx transmit data source select setting. - * - * This function selects the source for the LPSCIx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the LPSCIx transmit data - */ -static inline void SIM_HAL_SetLpsciTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpsci_txsrc_t select) -{ - SIM_BWR_SOPT5_UART0TXSRC(base, select); -} - -/*! - * @brief Gets the LPSCIx transmit data source select setting. - * - * This function gets the LPSCIx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select LPSCIx transmit data source select setting - */ -static inline sim_lpsci_txsrc_t SIM_HAL_GetLpsciTxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_lpsci_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); -} - -#if FSL_FEATURE_SIM_OPT_HAS_ODE - -/*! -* @brief Sets the UARTx Open Drain Enable setting. - - -* -* This function enables/disables the UARTx Open Drain. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @param enable Enable/disable UARTx Open Drain - - -* - True: Enable UARTx Open Drain -* - False: Disable UARTx Open Drain -*/ -void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable); - -/*! -* @brief Gets the UARTx Open Drain Enable setting. -* -* This function gets the UARTx Open Drain Enable setting. - - -* -* @param base Register base address of SIM. -* @param instance UART instance. -*/ -bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the LPSCIx Open Drain Enable setting. -* -* This function enables/disables the LPSCIx Open Drain. -* -* @param base Register base address of SIM. -* @param instance LPSCI instance. -* @param enable Enable/disable LPSCIx Open Drain -* - True: Enable LPSCIx Open Drain -* - False: Disable LPSCIx Open Drain -*/ -static inline void SIM_HAL_SetLpsciOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - SIM_BWR_SOPT5_UART0ODE(base, enable); -} - -/*! -* @brief Gets the LPSCIx Open Drain Enable setting. -* -* This function gets the LPSCIx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance LPSCI instance. -* @return enabled True if LPSCIx Open Drain is enabled. -*/ -static inline bool SIM_HAL_GetLpsciOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - return (bool)SIM_BRD_SOPT5_UART0ODE(base); -} -#endif - -#if FSL_FEATURE_SIM_OPT_HAS_TPM - -/*! -* @brief Sets the Timer/PWM x external clock pin select setting. -* -* This function selects the source of the Timer/PWM x external clock pin select. - - -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select Timer/PWM x external clock pin select -*/ - -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select); - -/*! -* @brief Gets the Timer/PWM x external clock pin select setting. -* -* This function gets the Timer/PWM x external clock pin select setting. - - -* -* @param base Base address for current SIM instance. -* @param instance device instance. -*/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the Timer/PWM x channel y input capture source select setting. -* -* This function selects the Timer/PWM x channel y input capture source. - - -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @param select Timer/PWM x channel y input capture source -*/ - -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select); - -/*! -* @brief Gets the Timer/PWM x channel y input capture source select setting. -* -* This function gets the Timer/PWM x channel y input capture source. - - -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -*/ - -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); -#endif - -/*! - * @brief Gets the Kinetis Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Family ID in the System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Family ID - */ -static inline uint32_t SIM_HAL_GetFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Sub-Family ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Sub-Family ID - */ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} - -/*! - * @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Series ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Series ID - */ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type * base) -{ - return SIM_BRD_SDID_SERIESID(base); -} - -/*! - * @brief Gets the Kinetis SramSize in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis SramSize in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis SramSize - */ -static inline uint32_t SIM_HAL_GetSramSize(SIM_Type * base) -{ - return SIM_BRD_SDID_SRAMSIZE(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the Kinetis Die ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Die ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Die ID - */ -static inline uint32_t SIM_HAL_GetDieId(SIM_Type * base) -{ - return SIM_BRD_SDID_DIEID(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_SIM_HAL_KL15Z4_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL16Z4/fsl_sim_hal_MKL16Z4.c b/KSDK_1.2.0/platform/hal/src/sim/MKL16Z4/fsl_sim_hal_MKL16Z4.c deleted file mode 100755 index 11e5e13..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL16Z4/fsl_sim_hal_MKL16Z4.c +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = 0U; - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable settingg - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, uint32_t instance, sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue =(sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - - if (altTrigEn) - { - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartOpenDrainCmd - * Description : Set UARTx Open Drain Enable setting - * This function will enable/disable the UARTx Open Drain. - * - *END**************************************************************************/ -void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 1: - SIM_BWR_SOPT5_UART1ODE(base, enable ? 1 : 0); - break; - case 2: - SIM_BWR_SOPT5_UART2ODE(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartOpenDrainCmd - * Description : Get UARTx Open Drain Enable setting - * This function will get UARTx Open Drain Enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 1: - retValue = SIM_BRD_SOPT5_UART1ODE(base); - break; - case 2: - retValue = SIM_BRD_SOPT5_UART2ODE(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmExternalClkPinSelMode - * Description : Set Timer/PWM x external clock pin select setting - * This function will select the source of Timer/PWM x external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_TPM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_TPM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_TPM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetTpmExternalClkPinSelMode - * Description : Get Timer/PWM x external clock pin select setting - * This function will get Timer/PWM x external clock pin select setting. - * - *END**************************************************************************/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance) -{ - sim_tpm_clk_sel_t retValue = (sim_tpm_clk_sel_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM0CLKSEL(base); - break; - case 1: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM1CLKSEL(base); - break; - case 2: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmChSrcMode - * Description : Timer/PWM x channel y input capture source select setting - * This function will select Timer/PWM x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - SIM_BWR_SOPT4_TPM1CH0SRC(base, select); - break; - case 2: - SIM_BWR_SOPT4_TPM2CH0SRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetTpmChSrcMode - * Description : Get Timer/PWM x channel y input capture source select setting - * This function will get Timer/PWM x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_tpm_ch_src_t retValue = (sim_tpm_ch_src_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM1CH0SRC(base); - break; - case 2: - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM2CH0SRC(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL16Z4/fsl_sim_hal_MKL16Z4.h b/KSDK_1.2.0/platform/hal/src/sim/MKL16Z4/fsl_sim_hal_MKL16Z4.h deleted file mode 100644 index fa6b9d1..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL16Z4/fsl_sim_hal_MKL16Z4.h +++ /dev/null @@ -1,1397 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_KL16Z4_H__) -#define __FSL_SIM_HAL_KL16Z4_H__ - - -/*! - * @addtogroup sim_hal_kl16z4 - * @{ - */ -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - - /*! @brief COP clock source select */ -typedef enum _clock_cop_src_t -{ - kClockCopSrcLpoClk, /*!< LPO */ - kClockCopSrcAltClk, /*!< Alternative clock, for KL16Z4 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_cop_src_kl16z4_t; -#else -} clock_cop_src_t; -#endif - -/*! @brief TPM clock source select */ -typedef enum _clock_tpm_src -{ - kClockTpmSrcNone, /*!< clock disabled */ - kClockTpmSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTpmSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTpmSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tpm_src_kl16z4_t; -#else -} clock_tpm_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG out clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk, /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_kl16z4_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief UART0 clock source select */ -typedef enum _clock_lpsci_src -{ - kClockLpsciSrcNone, /*!< clock disabled */ - kClockLpsciSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockLpsciSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockLpsciSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lpsci_src_kl16z4_t; -#else -} clock_lpsci_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB clock source select */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< USB CLKIN Clock */ - kClockUsbfsSrcPllFllSel /*!< clock as selected by SOPT2[PLLFLLSEL] */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_kl16z4_t; -#else -} clock_usbfs_src_t; -#endif -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_kl16z4_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll, /*!< Fll clock */ - kClockPllFllSelPll /*!< Pll0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_kl16z4_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL) */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC 32k clock */ - kClockEr32kSrcReserved = 1U, /*!< Reserved */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock */ - kClockEr32kSrcLpo = 3U /*!< LPO clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_kl16z4_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutReserved = 0U, /*!< Reserved */ - kClockClkoutReserved1 = 1U, /*!< Reserved */ - kClockClkoutBusClk = 2U, /*!< Bus clock */ - kClockClkoutLpoClk = 3U, /*!< LPO clock */ - kClockClkoutMcgIrClk = 4U, /*!< MCG ir clock */ - kClockClkoutReserved2 = 5U, /*!< Reserved */ - kClockClkoutOsc0erClk = 6U, /*!< OSC0ER clock */ - kClockClkoutReserved3 = 7U /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_kl16z4_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz /*!< 32KHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_kl16z4_t; -#else -} clock_rtcout_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_kl16z4_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_kl16z4_t; -#else -} sim_usbvstby_mode_t; -#endif -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_kl16z4_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelComp0 = 1U, /*!< CMP0 output */ - kSimAdcTrgSelReserved = 2U, /*!< Reserved */ - kSimAdcTrgSelReserved1 = 3U, /*!< Reserved */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelReserved2 = 6U, /*!< Reserved */ - kSimAdcTrgSelReserved3 = 7U, /*!< Reserved */ - kSimAdcTrgSelTpm0 = 8U, /*!< TPM0 overflow */ - kSimAdcTrgSelTpm1 = 9U, /*!< TPM1 overflow */ - kSimAdcTrgSelTpm2 = 10U, /*!< TPM2 overflow */ - kSimAdcTrgSelReserved4 = 11U, /*!< Reserved */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U, /*!< Low-power timer trigger */ - kSimAdcTrgSelReserved5 = 15U /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_kl16z4_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_kl16z4_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcTpm1, /*!< UARTx_TX pin modulated with TPM1 channel 0 output */ - kSimUartTxsrcTpm2, /*!< UARTx_TX pin modulated with TPM2 channel 0 output */ - kSimUartTxsrcReserved /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_kl16z4_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM LPSCI receive data source select */ -typedef enum _sim_lpsci_rxsrc -{ - kSimLpsciRxsrcPin, /*!< LPSCIx_RX Pin */ - kSimLpsciRxsrcCmp0, /*!< CMP0 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpsci_rxsrc_kl16z4_t; -#else -} sim_lpsci_rxsrc_t; -#endif - -/*! @brief SIM LPSCI transmit data source select */ -typedef enum _sim_lpsci_txsrc -{ - kSimLpsciTxsrcPin, /*!< LPSCIx_TX Pin */ - kSimLpsciTxsrcTpm1, /*!< LPSCIx_TX pin modulated with TPM1 channel 0 output */ - kSimLpsciTxsrcTpm2, /*!< LPSCIx_TX pin modulated with TPM2 channel 0 output */ - kSimLpsciTxsrcReserved /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpsci_txsrc_kl16z4_t; -#else -} sim_lpsci_txsrc_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_kl16z4_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1, /*!< CMP0 output */ - kSimTpmChSrc2, /*!< Reserved */ - kSimTpmChSrc3 /*!< USB start of frame pulse */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_kl16z4_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateLpsci0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), -#endif - kSimClockGateCmp0 = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(4U, 22U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(4U, 23U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGateTsi0 = FSL_SIM_SCGC_BIT(5U, 5U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), -#if FSL_FEATURE_SOC_LCD_COUNT - kSimClockGateSlcd0 = FSL_SIM_SCGC_BIT(5U, 19U), -#endif - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateTpm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateTpm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateTpm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(6U, 31U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 8U) -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_kl16z4_t; -#else -} sim_clock_gate_name_t; -#endif - -/*@}*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTpmSrc(SIM_Type * base, - uint32_t instance, - clock_tpm_src_t setting) -{ - SIM_BWR_SOPT2_TPMSRC(base, setting); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_HAL_GetTpmSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_tpm_src_t)SIM_BRD_SOPT2_TPMSRC(base); -} - -/*! - * @brief Set the LPSCI clock source selection. - * - * This function sets the LPSCI clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetLpsciSrc(SIM_Type * base, - uint32_t instance, - clock_lpsci_src_t setting) -{ - SIM_BWR_SOPT2_UART0SRC(base, setting); -} - -/*! - * @brief Get the LPSCI clock source selection. - * - * This function gets the LPSCI clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_lpsci_src_t CLOCK_HAL_GetLpsciSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_lpsci_src_t)SIM_BRD_SOPT2_UART0SRC(base); -} -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -static inline void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - SIM_BWR_SOPT5_UART1RXSRC(base, select); -} - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -static inline sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); -} - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -static inline void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - SIM_BWR_SOPT5_UART1TXSRC(base, select); -} - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -static inline sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); -} - -/*! - * @brief Sets the LPSCIx receive data source select setting. - * - * This function selects the source for the LPSCIx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the LPSCIx receive data - */ -static inline void SIM_HAL_SetLpsciRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpsci_rxsrc_t select) -{ - SIM_BWR_SOPT5_UART0RXSRC(base, select); -} - -/*! - * @brief Gets the LPSCIx receive data source select setting. - * - * This function gets the LPSCIx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select LPSCIx receive data source select setting - */ -static inline sim_lpsci_rxsrc_t SIM_HAL_GetLpsciRxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_lpsci_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); -} - -/*! - * @brief Sets the LPSCIx transmit data source select setting. - * - * This function selects the source for the LPSCIx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the LPSCIx transmit data - */ -static inline void SIM_HAL_SetLpsciTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpsci_txsrc_t select) -{ - SIM_BWR_SOPT5_UART0TXSRC(base, select); -} - -/*! - * @brief Gets the LPSCIx transmit data source select setting. - * - * This function gets the LPSCIx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select LPSCIx transmit data source select setting - */ -static inline sim_lpsci_txsrc_t SIM_HAL_GetLpsciTxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_lpsci_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); -} - -#if FSL_FEATURE_SIM_OPT_HAS_ODE -/*! -* @brief Sets the UARTx Open Drain Enable setting. -* -* This function enables/disables the UARTx Open Drain. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @param enable Enable/disable UARTx Open Drain -* - True: Enable UARTx Open Drain -* - False: Disable UARTx Open Drain -*/ -void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable); - -/*! -* @brief Gets the UARTx Open Drain Enable setting. -* -* This function gets the UARTx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @return enabled True if UARTx Open Drain is enabled. -*/ -bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the LPSCIx Open Drain Enable setting. -* -* This function enables/disables the LPSCIx Open Drain. -* -* @param base Register base address of SIM. -* @param instance LPSCI instance. -* @param enable Enable/disable LPSCIx Open Drain -* - True: Enable LPSCIx Open Drain -* - False: Disable LPSCIx Open Drain -*/ -static inline void SIM_HAL_SetLpsciOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - SIM_BWR_SOPT5_UART0ODE(base, enable); -} - -/*! -* @brief Gets the LPSCIx Open Drain Enable setting. -* -* This function gets the LPSCIx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance LPSCI instance. -* @return enabled True if LPSCIx Open Drain is enabled. -*/ -static inline bool SIM_HAL_GetLpsciOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - return (bool)SIM_BRD_SOPT5_UART0ODE(base); -} -#endif - -#if FSL_FEATURE_SIM_OPT_HAS_TPM -/*! -* @brief Sets the Timer/PWM x external clock pin select setting. -* -* This function selects the source of the Timer/PWM x external clock pin select. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select Timer/PWM x external clock pin select -*/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select); - -/*! -* @brief Gets the Timer/PWM x external clock pin select setting. -* -* This function gets the Timer/PWM x external clock pin select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return Timer/PWM x external clock pin select setting -*/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the Timer/PWM x channel y input capture source select setting. -* -* This function selects the Timer/PWM x channel y input capture source. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @param select Timer/PWM x channel y input capture source -*/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select); - -/*! -* @brief Gets the Timer/PWM x channel y input capture source select setting. -* -* This function gets the Timer/PWM x channel y input capture source. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @return select Timer/PWM x channel y input capture source -*/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); -#endif - -/*! - * @brief Gets the Kinetis Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Family ID in the System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Family ID - */ -static inline uint32_t SIM_HAL_GetFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Sub-Family ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Sub-Family ID - */ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} - -/*! - * @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Series ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Series ID - */ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type * base) -{ - return SIM_BRD_SDID_SERIESID(base); -} - -/*! - * @brief Gets the Kinetis SramSize in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis SramSize in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis SramSize - */ -static inline uint32_t SIM_HAL_GetSramSize(SIM_Type * base) -{ - return SIM_BRD_SDID_SRAMSIZE(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the Kinetis Die ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Die ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Die ID - */ -static inline uint32_t SIM_HAL_GetDieId(SIM_Type * base) -{ - return SIM_BRD_SDID_DIEID(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_SIM_HAL_KL16Z4_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL17Z4/fsl_sim_hal_MKL17Z4.c b/KSDK_1.2.0/platform/hal/src/sim/MKL17Z4/fsl_sim_hal_MKL17Z4.c deleted file mode 100755 index 58799fb..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL17Z4/fsl_sim_hal_MKL17Z4.c +++ /dev/null @@ -1,384 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* -* Definitions -******************************************************************************/ - -/******************************************************************************* -* APIs -******************************************************************************/ - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_HAL_SetOutDiv -* Description : Set all clock out dividers setting at the same time -* This function will set the setting for all clock out dividers. -* -*END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = 0U; - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetLpuartSrc - * Description : Set the clock selection of LPUART. - * This function sets the clock selection of LPUART. - * - *END**************************************************************************/ -void CLOCK_HAL_SetLpuartSrc(SIM_Type * base, - uint32_t instance, - clock_lpuart_src_t setting) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0u == instance) - { - SIM_BWR_SOPT2_LPUART0SRC(base, setting); - } - else - { - SIM_BWR_SOPT2_LPUART1SRC(base, setting); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetLpuartSrc - * Description : Get the clock selection of LPUART. - * This function gets the clock selection of LPUART. - * - *END**************************************************************************/ -clock_lpuart_src_t CLOCK_HAL_GetLpuartSrc(SIM_Type * base, - uint32_t instance) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0u == instance) - { - return (clock_lpuart_src_t)SIM_BRD_SOPT2_LPUART0SRC(base); - } - else - { - return (clock_lpuart_src_t)SIM_BRD_SOPT2_LPUART1SRC(base); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmChSrcMode - * Description : Sets the Timer/PWM x channel y input capture source. - * - *END**************************************************************************/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select) -{ - assert(instance < TPM_INSTANCE_COUNT); - - if(instance == 1) - { - SIM_BWR_SOPT4_TPM1CH0SRC(base, select); - } - else if(instance == 2) - { - SIM_BWR_SOPT4_TPM2CH0SRC(base, select); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmChSrcMode - * Description : Sets the Timer/PWM x channel y input capture source. - * - *END**************************************************************************/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - assert(instance < TPM_INSTANCE_COUNT); - - sim_tpm_ch_src_t retValue = (sim_tpm_ch_src_t)0; - - if(instance == 1) - { - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM1CH0SRC(base); - } - else if(instance == 2) - { - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM2CH0SRC(base); - } - - return retValue; -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetLpuartRxSrcMode -* Description : Sets the LPUARTx receive data source select setting. -* -*END**************************************************************************/ -void SIM_HAL_SetLpuartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpuart_rxsrc_t select) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - SIM_BWR_SOPT5_LPUART0RXSRC(base, select); - } - else - { - SIM_BWR_SOPT5_LPUART1RXSRC(base, select); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_GetLpuartRxSrcMode -* Description : Gets the LPUARTx receive data source select setting. -* -*END**************************************************************************/ -sim_lpuart_rxsrc_t SIM_HAL_GetLpuartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - return (sim_lpuart_rxsrc_t)SIM_BRD_SOPT5_LPUART0RXSRC(base); - } - else - { - return (sim_lpuart_rxsrc_t)SIM_BRD_SOPT5_LPUART1RXSRC(base); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetLpuartTxSrcMode -* Description : Sets the LPUARTx transmit data source select setting. -* -*END**************************************************************************/ -void SIM_HAL_SetLpuartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpuart_txsrc_t select) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - SIM_BWR_SOPT5_LPUART0TXSRC(base, select); - } - else - { - SIM_BWR_SOPT5_LPUART1TXSRC(base, select); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetLpuartTxSrcMode -* Description : Sets the LPUARTx transmit data source select setting. -* -*END**************************************************************************/ -sim_lpuart_txsrc_t SIM_HAL_GetLpuartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - return (sim_lpuart_txsrc_t)SIM_BRD_SOPT5_LPUART0TXSRC(base); - } - else - { - return (sim_lpuart_txsrc_t)SIM_BRD_SOPT5_LPUART1TXSRC(base); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetLpuartOpenDrainCmd -* Description : This function enables/disables the LPUARTx Open Drain. -* -*END**************************************************************************/ -void SIM_HAL_SetLpuartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - SIM_BWR_SOPT5_LPUART0ODE(base, enable ? 1 : 0); - } - else - { - SIM_BWR_SOPT5_LPUART1ODE(base, enable ? 1 : 0); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_GetLpuartOpenDrainCmd -* Description : This function gets the LPUARTx Open Drain setting. -* -*END**************************************************************************/ -bool SIM_HAL_GetLpuartOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - return (bool)SIM_BRD_SOPT5_LPUART0ODE(base); - } - else - { - return (bool)SIM_BRD_SOPT5_LPUART1ODE(base); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetAdcTriggerModeOneStep -* Description : Set ADCx trigger setting. -* This function sets ADC alternate trigger, pre-trigger mode and trigger mode. -* -*END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - - if (altTrigEn) - { - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - } - -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetTpmExternalClkPinSelMode -* Description : Set Timer/PWM x external clock pin select setting -* This function will select the source of Timer/PWM x external clock pin select -* -*END**************************************************************************/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_TPM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_TPM1CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_GetTpmExternalClkPinSelMode -* Description : Get Timer/PWM x external clock pin select setting -* This function will get Timer/PWM x external clock pin select setting. -* -*END**************************************************************************/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance) -{ - sim_tpm_clk_sel_t retValue = (sim_tpm_clk_sel_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM0CLKSEL(base); - break; - case 1: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM1CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* -* EOF -******************************************************************************/ diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL17Z4/fsl_sim_hal_MKL17Z4.h b/KSDK_1.2.0/platform/hal/src/sim/MKL17Z4/fsl_sim_hal_MKL17Z4.h deleted file mode 100644 index 9e3af9a..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL17Z4/fsl_sim_hal_MKL17Z4.h +++ /dev/null @@ -1,1371 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#if !defined(__FSL_SIM_HAL_MKL17Z4_H__) -#define __FSL_SIM_HAL_MKL17Z4_H__ - - -/*! - * @addtogroup sim_hal_kl17z4 - * @{ - */ -/*! @file*/ - -/******************************************************************************* -* Definitions -******************************************************************************/ -/*! @brief COP clock source selection.*/ -typedef enum _clock_cop_src { - kClockCopSrcLpoClk, /*!< LPO clock 1K HZ.*/ - kClockCopSrcMcgIrClk, /*!< MCG IRC Clock */ - kClockCopSrcOsc0erClk, /*!< OSCER Clock */ - kClockCopSrcBusClk /*!< BUS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -}clock_cop_src_kl17z4_t; -#else -}clock_cop_src_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U, /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_kl17z4_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM external reference clock output pin select (OSC32KOUT). */ -typedef enum _clock_osc32kout_sel -{ - kClockOsc32koutNone = 0U, /*!< ERCLK32K is not output. */ - kClockOsc32koutPte0 = 1U, /*!< ERCLK32K is output on PTE0. */ - kClockOsc32koutPte26 = 2U, /*!< ERCLK32K is output on PTE26. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_osc32kout_sel_kl17z4_t; -#else -} clock_osc32kout_sel_t; -#endif - -/*! @brief SIM LPUART clock source */ -typedef enum _clock_lpuart_src -{ - kClockLpuartSrcNone, /*!< disabled */ - kClockLpuartSrcIrc48M, /*!< IRC48M */ - kClockLpuartSrcOsc0erClk, /*!< OSCER clock */ - kClockLpuartSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lpuart_src_kl17z4_t; -#else -} clock_lpuart_src_t; -#endif - -/*! @brief SIM TPM clock source */ -typedef enum _clock_tpm_src -{ - kClockTpmSrcNone, /*!< disabled */ - kClockTpmSrcIrc48M, /*!< IRC48M/MCGPCLK */ - kClockTpmSrcOsc0erClk, /*!< OSCER clock */ - kClockTpmSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tpm_src_kl17z4_t; -#else -} clock_tpm_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcIrc48M, /*!< IRC48/MCGPCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_kl17z4_t; -#else -} clock_usbfs_src_t; -#endif -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! @brief FLEXIO clock source. */ -typedef enum _clock_flexio_src -{ - kClockFlexioSrcNone, /*!< Clock disabled. */ - kClockFlexioSrcIrc48M, /*!< MCGPCLK/IRC48M. */ - kClockFlexioSrcOsc0erClk, /*!< OSCERCLK. */ - kClockFlexioSrcMcgIrClk, /*!< MCGIRCLK. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_flexio_src_kl17z4_t; -#else -} clock_flexio_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG out clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk, /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_kl17z4_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCG out clock */ - kClockClkoutSelOsc0erClk = 6U, /*!< OSCER clock */ - kClockClkoutSelIrc48M = 7U /*!< IRC48M clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_kl17z4_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrcOsc0erClk, /*!< OSCER clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_kl17z4_t; -#else -} clock_rtcout_src_t; -#endif - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_kl17z4_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelComp0 = 1U, /*!< CMP0 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelTpm0 = 8U, /*!< TPM0 overflow */ - kSimAdcTrgSelTpm1 = 9U, /*!< TPM1 overflow */ - kSimAdcTrgSelTpm2 = 10U, /*!< TPM2 overflow */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U, /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_kl17z4_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief LPUART receive data source. */ -typedef enum _sim_lpuart_rxsrc -{ - kSimLpuartRxsrcPin, /*!< LPUARTx_RX Pin */ - kSimLpuartRxsrcCmp0, /*!< CMP0 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpuart_rxsrc_kl17z4_t; -#else -} sim_lpuart_rxsrc_t; -#endif - -/*! @brief LPUART transmit data source. */ -typedef enum _sim_lpuart_txsrc -{ - kSimLpuartTxsrcPin, /*!< UARTx_TX Pin */ - kSimLpuartTxsrcTpm1, /*!< UARTx_TX pin modulated with TPM1 channel 0 output */ - kSimLpuartTxsrcTpm2, /*!< UARTx_TX pin modulated with TPM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpuart_txsrc_kl17z4_t; -#else -} sim_lpuart_txsrc_t; -#endif - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcMcgIrClk = 2U, /*!< MCGIRCLK */ - kClockSaiSrcIrc48M = 3U, /*!< MCGPCLK/IRC48M. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_kl17z4_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_kl17z4_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< Channel y input capture source uses 0. */ - kSimTpmChSrc1, /*!< Channel y input capture source uses 1. */ - kSimTpmChSrc2, /*!< Channel y input capture source uses 2. */ - kSimTpmChSrc3, /*!< Channel y input capture source uses 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_kl17z4_t; -#else -} sim_tpm_ch_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_kl17z4_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_kl17z4_t; -#else -} sim_usbvstby_mode_t; -#endif -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), -#endif - kSimClockGateCmp0 = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(4U, 22U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(4U, 23U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), -#if FSL_FEATURE_SOC_LCD_COUNT - kSimClockGateSlcd0 = FSL_SIM_SCGC_BIT(5U, 19U), -#endif - kSimClockGateLpuart0 = FSL_SIM_SCGC_BIT(5U, 20U), - kSimClockGateLpuart1 = FSL_SIM_SCGC_BIT(5U, 21U), - kSimClockGateFlexio0 = FSL_SIM_SCGC_BIT(5U, 31U), - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateTpm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateTpm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateTpm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(6U, 31U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 8U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_kl17z4_t; -#else -} sim_clock_gate_name_t; -#endif - -/*@}*/ - -/******************************************************************************* -* API -******************************************************************************/ -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! -* @brief Disable the clock for specific module. -* -* This function disables the clock for specific module. -* -* @param base Base address for current SIM instance. -* @param name Name of the module to disable. -*/ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! -* @brief Get the the clock gate state for specific module. -* -* This function will get the clock gate state for specific module. -* -* @param base Base address for current SIM instance. -* @param name Name of the module to get. -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! -* @brief Set the clock selection of LPUART. -* -* This function sets the clock selection of LPUART. -* -* @param base Base address for current SIM instance. -* @param instance LPUART instance. -* @param setting The value to set. -*/ -void CLOCK_HAL_SetLpuartSrc(SIM_Type * base, - uint32_t instance, - clock_lpuart_src_t setting); - -/*! -* @brief Get the clock selection of LPUART. -* -* This function gets the clock selection of LPUART. -* -* @param base Base address for current SIM instance. -* @param instance LPUART instance. -* @return Current selection. -*/ -clock_lpuart_src_t CLOCK_HAL_GetLpuartSrc(SIM_Type * base, - uint32_t instance); - -/*! -* @brief Set the clock selection of TPM. -* -* This function sets the clock selection of TPM. -* -* @param base Base address for current SIM instance. -* @param instance IP instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetTpmSrc(SIM_Type * base, - uint32_t instance, - clock_tpm_src_t setting) -{ - SIM_BWR_SOPT2_TPMSRC(base, setting); -} - -/*! -* @brief Get the clock selection of TPM. -* -* This function gets the clock selection of TPM. -* -* @param base Base address for current SIM instance. -* @param instance IP instance. -* @return Current selection. -*/ -static inline clock_tpm_src_t CLOCK_HAL_GetTpmSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_tpm_src_t)SIM_BRD_SOPT2_TPMSRC(base); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Select the clock source for FLEXIO. - * - * This function selects the clock source for FLEXIO. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetFlexioSrc(SIM_Type * base, - uint32_t instance, - clock_flexio_src_t setting) -{ - SIM_BWR_SOPT2_FLEXIOSRC(base, setting); -} - -/*! - * @brief Get the clock source of FLEXIO. - * - * This function gets the clock source of FLEXIO. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_flexio_src_t CLOCK_HAL_GetFlexioSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_flexio_src_t)SIM_BRD_SOPT2_FLEXIOSRC(base); -} - -/*! -* @brief Set the clock ERCLK32K output on selected pin. -* -* This function sets ERCLK32K output on selected pin. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetOsc32kOutSel(SIM_Type * base, - clock_osc32kout_sel_t setting) -{ - SIM_BWR_SOPT1_OSC32KOUT(base, setting); -} - -/*! -* @brief Get output status of ERCLK32K. -* -* This function gets the output status of ERCLK32K. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_osc32kout_sel_t CLOCK_HAL_GetOsc32kOutSel(SIM_Type * base) -{ - return (clock_osc32kout_sel_t)SIM_BRD_SOPT1_OSC32KOUT(base); -} - - -/*! -* @brief Set the clock selection of ERCLK32K. -* -* This function sets the clock selection of ERCLK32K. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! -* @brief Get the clock selection of ERCLK32K. -* -* This function gets the clock selection of ERCLK32K. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! -* @brief Set CLKOUTSEL selection. -* -* This function sets the selection of the clock to output on the CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! -* @brief Get CLKOUTSEL selection. -* -* This function gets the selection of the clock to output on the CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! -* @brief Set RTCCLKOUTSEL selection. -* -* This function sets the selection of the clock to output on the RTC_CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! -* @brief Get RTCCLKOUTSEL selection. -* -* This function gets the selection of the clock to output on the RTC_CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - - -/*! -* @brief Set the clock selection of COP. -* -* This function sets the clock selection of COP. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetCopSrc(SIM_Type * base, - clock_cop_src_t setting) -{ - SIM_BWR_COPC_COPCLKSEL(base, setting); -} - -/*! -* @brief Get the clock selection of COP. -* -* This function gets the clock selection of COP. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_cop_src_t CLOCK_HAL_GetCopSrc(SIM_Type * base) -{ - return (clock_cop_src_t)SIM_BRD_COPC_COPCLKSEL(base); -} - - -/*! -* @brief Set OUTDIV1. -* -* This function sets divide value OUTDIV1. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! -* @brief Get OUTDIV1. -* -* This function gets divide value OUTDIV1. -* -* @param base Base address for current SIM instance. -* @return Current divide value. -*/ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! -* @brief Set OUTDIV4. -* -* This function sets divide value OUTDIV4. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! -* @brief Get OUTDIV4. -* -* This function gets divide value OUTDIV4. -* -* @param base Base address for current SIM instance. -* @return Current divide value. -*/ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif //FSL_FEATURE_SOC_USB_COUNT - -/*! -* @brief Sets the ADCx alternate trigger enable setting. -* -* This function enables/disables the alternative conversion triggers for ADCx. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param enable Enable alternative conversion triggers for ADCx -* - true: Select alternative conversion trigger. -* - false: Select PDB trigger. -*/ -static inline void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - -} - -/*! -* @brief Gets the ADCx alternate trigger enable setting. -* -* This function gets the ADCx alternate trigger enable setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return enabled True if ADCx alternate trigger is enabled -*/ - -static inline bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - - return retValue; -} - -/*! -* @brief Sets the ADCx pre-trigger select setting. -* -* This function selects the ADCx pre-trigger source when the alternative -* triggers are enabled through ADCxALTTRGEN. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select pre-trigger select setting for ADCx -*/ -static inline void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - -} -/*! -* @brief Gets the ADCx pre-trigger select setting. -* -* This function gets the ADCx pre-trigger select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return select ADCx pre-trigger select setting -*/ -static inline sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - - return retValue; -} - -/*! -* @brief Sets the ADCx trigger select setting. -* -* This function selects the ADCx trigger source when alternative triggers -* are enabled through ADCxALTTRGEN. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select trigger select setting for ADCx -*/ -static inline void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - -} - -/*! -* @brief Gets the ADCx trigger select setting. -* -* This function gets the ADCx trigger select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return ADCx trigger select setting -*/ -static inline sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - - return retValue; -} - -/*! -* @brief Sets the ADCx trigger select setting in one function. -* -* This function sets ADC alternate trigger, pre-trigger mode and trigger mode. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param altTrigEn Alternative trigger enable or not. -* @param preTrigSel Pre-trigger mode. -* @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! -* @brief Sets the LPUARTx receive data source select setting. -* -* This function selects the source for the LPUARTx receive data. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @param select the source for the LPUARTx receive data -*/ -void SIM_HAL_SetLpuartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpuart_rxsrc_t select); - -/*! -* @brief Gets the LPUARTx receive data source select setting. -* -* This function gets the LPUARTx receive data source select setting. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* -* @return select UARTx receive data source select setting -*/ -sim_lpuart_rxsrc_t SIM_HAL_GetLpuartRxSrcMode(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the LPUARTx transmit data source select setting. -* -* This function selects the source for the LPUARTx transmit data. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @param select the source for the UARTx transmit data. -*/ -void SIM_HAL_SetLpuartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpuart_txsrc_t select); - -/*! -* @brief Gets the LPUARTx transmit data source select setting. -* -* This function gets the LPUARTx transmit data source select setting. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @return select UARTx transmit data source select setting. -*/ -sim_lpuart_txsrc_t SIM_HAL_GetLpuartTxSrcMode(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the LPUARTx Open Drain Enable setting. -* -* This function enables/disables the LPUARTx Open Drain. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @param enable Enable/disable LPUARTx Open Drain -* - True: Enable LPUARTx Open Drain -* - False: Disable LPUARTx Open Drain -*/ -void SIM_HAL_SetLpuartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable); - -/*! -* @brief Gets the LPUARTx Open Drain Enable setting. -* -* This function gets the LPUARTx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @return enabled True if LPUARTx Open Drain is enabled. -*/ -bool SIM_HAL_GetLpuartOpenDrainCmd(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the UARTx Open Drain Enable setting. -* -* This function enables/disables the UARTx Open Drain. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @param enable Enable/disable UARTx Open Drain -* - True: Enable UARTx Open Drain -* - False: Disable UARTx Open Drain -*/ -static inline void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - // Only support UART2 - assert (2 == instance); - SIM_BWR_SOPT5_UART2ODE(base, enable ? 1 : 0); -} - -/*! -* @brief Gets the UARTx Open Drain Enable setting. -* -* This function gets the UARTx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @return enabled True if UARTx Open Drain is enabled. -*/ -static inline bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, - uint32_t instance) -{ - // Only support UART2 - assert (2 == instance); - return (bool)SIM_BRD_SOPT5_UART2ODE(base); -} - -/*! -* @brief Sets the Timer/PWM x channel y input capture source select setting. -* -* This function selects the Timer/PWM x channel y input capture source. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @param select Timer/PWM x channel y input capture source -*/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select); - -/*! -* @brief Gets the Timer/PWM x channel y input capture source select setting. -* -* This function gets the Timer/PWM x channel y input capture source select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel Tpm channel y -* @return select Timer/PWM x channel y input capture source select setting -*/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! -* @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Sub-Family ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Sub-Family ID -*/ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} - -/*! -* @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Series ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Series ID -*/ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type * base) -{ - return SIM_BRD_SDID_SERIESID(base); -} - -/*! -* @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Fam ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Fam ID -*/ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! -* @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Pincount ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Pincount ID -*/ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! -* @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Revision ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Revision ID -*/ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! -* @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function gets the program flash size in the Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @return size Program flash Size -*/ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! -* @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function sets the Flash Doze in the Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @param setting Flash Doze setting -*/ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! -* @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function gets the Flash Doze in the Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @return setting Flash Doze setting -*/ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! -* @brief Sets the Flash disable setting. -* -* This function sets the Flash disable setting in the -* Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @param disable Flash disable setting -*/ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! -* @brief Gets the Flash disable setting. -* -* This function gets the Flash disable setting in the -* Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @return setting Flash disable setting -*/ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! -* @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function gets the Flash maximum block 0 in Flash Configuration Register 2. -* -* @param base Base address for current SIM instance. -* @return address Flash maximum block 0 address -*/ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -/*! -* @brief Sets the Timer/PWM x external clock pin select setting. -* -* This function selects the source of the Timer/PWM x external clock pin select. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select Timer/PWM x external clock pin select -* - 0: Timer/PWM x external clock driven by the TPM_CLKIN0 pin. -* - 1: Timer/PWM x external clock driven by the TPM_CLKIN1 pin. -*/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select); - -/*! -* @brief Gets the Timer/PWM x external clock pin select setting. -* -* This function gets the Timer/PWM x external clock pin select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return select Timer/PWM x external clock pin select setting -*/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance); - - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_SIM_HAL_MKL17Z4_H__*/ -/******************************************************************************* -* EOF -******************************************************************************/ diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL17Z644/fsl_sim_hal_MKL17Z644.c b/KSDK_1.2.0/platform/hal/src/sim/MKL17Z644/fsl_sim_hal_MKL17Z644.c deleted file mode 100755 index 58799fb..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL17Z644/fsl_sim_hal_MKL17Z644.c +++ /dev/null @@ -1,384 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* -* Definitions -******************************************************************************/ - -/******************************************************************************* -* APIs -******************************************************************************/ - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_HAL_SetOutDiv -* Description : Set all clock out dividers setting at the same time -* This function will set the setting for all clock out dividers. -* -*END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = 0U; - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetLpuartSrc - * Description : Set the clock selection of LPUART. - * This function sets the clock selection of LPUART. - * - *END**************************************************************************/ -void CLOCK_HAL_SetLpuartSrc(SIM_Type * base, - uint32_t instance, - clock_lpuart_src_t setting) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0u == instance) - { - SIM_BWR_SOPT2_LPUART0SRC(base, setting); - } - else - { - SIM_BWR_SOPT2_LPUART1SRC(base, setting); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetLpuartSrc - * Description : Get the clock selection of LPUART. - * This function gets the clock selection of LPUART. - * - *END**************************************************************************/ -clock_lpuart_src_t CLOCK_HAL_GetLpuartSrc(SIM_Type * base, - uint32_t instance) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0u == instance) - { - return (clock_lpuart_src_t)SIM_BRD_SOPT2_LPUART0SRC(base); - } - else - { - return (clock_lpuart_src_t)SIM_BRD_SOPT2_LPUART1SRC(base); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmChSrcMode - * Description : Sets the Timer/PWM x channel y input capture source. - * - *END**************************************************************************/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select) -{ - assert(instance < TPM_INSTANCE_COUNT); - - if(instance == 1) - { - SIM_BWR_SOPT4_TPM1CH0SRC(base, select); - } - else if(instance == 2) - { - SIM_BWR_SOPT4_TPM2CH0SRC(base, select); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmChSrcMode - * Description : Sets the Timer/PWM x channel y input capture source. - * - *END**************************************************************************/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - assert(instance < TPM_INSTANCE_COUNT); - - sim_tpm_ch_src_t retValue = (sim_tpm_ch_src_t)0; - - if(instance == 1) - { - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM1CH0SRC(base); - } - else if(instance == 2) - { - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM2CH0SRC(base); - } - - return retValue; -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetLpuartRxSrcMode -* Description : Sets the LPUARTx receive data source select setting. -* -*END**************************************************************************/ -void SIM_HAL_SetLpuartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpuart_rxsrc_t select) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - SIM_BWR_SOPT5_LPUART0RXSRC(base, select); - } - else - { - SIM_BWR_SOPT5_LPUART1RXSRC(base, select); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_GetLpuartRxSrcMode -* Description : Gets the LPUARTx receive data source select setting. -* -*END**************************************************************************/ -sim_lpuart_rxsrc_t SIM_HAL_GetLpuartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - return (sim_lpuart_rxsrc_t)SIM_BRD_SOPT5_LPUART0RXSRC(base); - } - else - { - return (sim_lpuart_rxsrc_t)SIM_BRD_SOPT5_LPUART1RXSRC(base); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetLpuartTxSrcMode -* Description : Sets the LPUARTx transmit data source select setting. -* -*END**************************************************************************/ -void SIM_HAL_SetLpuartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpuart_txsrc_t select) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - SIM_BWR_SOPT5_LPUART0TXSRC(base, select); - } - else - { - SIM_BWR_SOPT5_LPUART1TXSRC(base, select); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetLpuartTxSrcMode -* Description : Sets the LPUARTx transmit data source select setting. -* -*END**************************************************************************/ -sim_lpuart_txsrc_t SIM_HAL_GetLpuartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - return (sim_lpuart_txsrc_t)SIM_BRD_SOPT5_LPUART0TXSRC(base); - } - else - { - return (sim_lpuart_txsrc_t)SIM_BRD_SOPT5_LPUART1TXSRC(base); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetLpuartOpenDrainCmd -* Description : This function enables/disables the LPUARTx Open Drain. -* -*END**************************************************************************/ -void SIM_HAL_SetLpuartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - SIM_BWR_SOPT5_LPUART0ODE(base, enable ? 1 : 0); - } - else - { - SIM_BWR_SOPT5_LPUART1ODE(base, enable ? 1 : 0); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_GetLpuartOpenDrainCmd -* Description : This function gets the LPUARTx Open Drain setting. -* -*END**************************************************************************/ -bool SIM_HAL_GetLpuartOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - return (bool)SIM_BRD_SOPT5_LPUART0ODE(base); - } - else - { - return (bool)SIM_BRD_SOPT5_LPUART1ODE(base); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetAdcTriggerModeOneStep -* Description : Set ADCx trigger setting. -* This function sets ADC alternate trigger, pre-trigger mode and trigger mode. -* -*END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - - if (altTrigEn) - { - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - } - -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetTpmExternalClkPinSelMode -* Description : Set Timer/PWM x external clock pin select setting -* This function will select the source of Timer/PWM x external clock pin select -* -*END**************************************************************************/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_TPM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_TPM1CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_GetTpmExternalClkPinSelMode -* Description : Get Timer/PWM x external clock pin select setting -* This function will get Timer/PWM x external clock pin select setting. -* -*END**************************************************************************/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance) -{ - sim_tpm_clk_sel_t retValue = (sim_tpm_clk_sel_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM0CLKSEL(base); - break; - case 1: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM1CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* -* EOF -******************************************************************************/ diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL17Z644/fsl_sim_hal_MKL17Z644.h b/KSDK_1.2.0/platform/hal/src/sim/MKL17Z644/fsl_sim_hal_MKL17Z644.h deleted file mode 100644 index 46b037f..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL17Z644/fsl_sim_hal_MKL17Z644.h +++ /dev/null @@ -1,1124 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#if !defined(__FSL_SIM_HAL_MKL17Z644_H__) -#define __FSL_SIM_HAL_MKL17Z644_H__ - -/*! - * @addtogroup sim_hal_kl17z644 - * @{ - */ -/*! @file*/ - -/******************************************************************************* -* Definitions -******************************************************************************/ -/*! @brief COP clock source selection.*/ -typedef enum _clock_cop_src { - kClockCopSrcLpoClk, /*!< LPO clock 1K HZ.*/ - kClockCopSrcMcgIrClk, /*!< MCG IRC Clock */ - kClockCopSrcOsc0erClk, /*!< OSCER Clock */ - kClockCopSrcBusClk /*!< BUS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -}clock_cop_src_kl17z644_t; -#else -}clock_cop_src_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U, /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_kl17z644_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM external reference clock output pin select (OSC32KOUT). */ -typedef enum _clock_osc32kout_sel -{ - kClockOsc32koutNone, /*!< ERCLK32K is not output. */ - kClockOsc32koutPte0, /*!< ERCLK32K output on PTE0 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_osc32kout_sel_kl17z644_t; -#else -} clock_osc32kout_sel_t; -#endif - -/*! @brief SIM LPUART clock source */ -typedef enum _clock_lpuart_src -{ - kClockLpuartSrcNone, /*!< disabled */ - kClockLpuartSrcIrc48M, /*!< IRC48M */ - kClockLpuartSrcOsc0erClk, /*!< OSCER clock */ - kClockLpuartSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lpuart_src_kl17z644_t; -#else -} clock_lpuart_src_t; -#endif - -/*! @brief SIM TPM clock source */ -typedef enum _clock_tpm_src -{ - kClockTpmSrcNone, /*!< disabled */ - kClockTpmSrcIrc48M, /*!< IRC48M/MCGPCLK */ - kClockTpmSrcOsc0erClk, /*!< OSCER clock */ - kClockTpmSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tpm_src_kl17z644_t; -#else -} clock_tpm_src_t; -#endif - -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcIrc48M, /*!< IRC48/MCGPCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_kl17z644_t; -#else -} clock_usbfs_src_t; -#endif - -/*! @brief FLEXIO clock source. */ -typedef enum _clock_flexio_src -{ - kClockFlexioSrcNone, /*!< Clock disabled. */ - kClockFlexioSrcIrc48M, /*!< MCGPCLK/IRC48M. */ - kClockFlexioSrcOsc0erClk, /*!< OSCERCLK. */ - kClockFlexioSrcMcgIrClk, /*!< MCGIRCLK. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_flexio_src_kl17z644_t; -#else -} clock_flexio_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG out clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk, /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_kl17z644_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCG out clock */ - kClockClkoutSelOsc0erClk = 6U, /*!< OSCER clock */ - kClockClkoutSelIrc48M = 7U /*!< IRC48M clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_kl17z644_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrcOsc0erClk, /*!< OSCER clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_kl17z644_t; -#else -} clock_rtcout_src_t; -#endif - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_kl17z644_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelComp0 = 1U, /*!< CMP0 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelTpm0 = 8U, /*!< TPM0 overflow */ - kSimAdcTrgSelTpm1 = 9U, /*!< TPM1 overflow */ - kSimAdcTrgSelTpm2 = 10U, /*!< TPM2 overflow */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U, /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_kl17z644_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief LPUART receive data source. */ -typedef enum _sim_lpuart_rxsrc -{ - kSimLpuartRxsrcPin, /*!< LPUARTx_RX Pin */ - kSimLpuartRxsrcCmp0, /*!< CMP0 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpuart_rxsrc_kl17z644_t; -#else -} sim_lpuart_rxsrc_t; -#endif - -/*! @brief LPUART transmit data source. */ -typedef enum _sim_lpuart_txsrc -{ - kSimLpuartTxsrcPin, /*!< UARTx_TX Pin */ - kSimLpuartTxsrcTpm1, /*!< UARTx_TX pin modulated with TPM1 channel 0 output */ - kSimLpuartTxsrcTpm2, /*!< UARTx_TX pin modulated with TPM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpuart_txsrc_kl17z644_t; -#else -} sim_lpuart_txsrc_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_kl17z644_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< Channel y input capture source uses 0. */ - kSimTpmChSrc1, /*!< Channel y input capture source uses 1. */ - kSimTpmChSrc2, /*!< Channel y input capture source uses 2. */ - kSimTpmChSrc3, /*!< Channel y input capture source uses 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_kl17z644_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), - kSimClockGateCmp0 = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(4U, 22U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(4U, 23U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - kSimClockGateLpuart0 = FSL_SIM_SCGC_BIT(5U, 20U), - kSimClockGateLpuart1 = FSL_SIM_SCGC_BIT(5U, 21U), - kSimClockGateFlexio0 = FSL_SIM_SCGC_BIT(5U, 31U), - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateTpm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateTpm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateTpm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 8U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_kl17z644_t; -#else -} sim_clock_gate_name_t; -#endif - -/*@}*/ - -/******************************************************************************* -* API -******************************************************************************/ -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! -* @brief Disable the clock for specific module. -* -* This function disables the clock for specific module. -* -* @param base Base address for current SIM instance. -* @param name Name of the module to disable. -*/ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! -* @brief Get the the clock gate state for specific module. -* -* This function will get the clock gate state for specific module. -* -* @param base Base address for current SIM instance. -* @param name Name of the module to get. -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! -* @brief Set the clock selection of LPUART. -* -* This function sets the clock selection of LPUART. -* -* @param base Base address for current SIM instance. -* @param instance LPUART instance. -* @param setting The value to set. -*/ -void CLOCK_HAL_SetLpuartSrc(SIM_Type * base, - uint32_t instance, - clock_lpuart_src_t setting); - -/*! -* @brief Get the clock selection of LPUART. -* -* This function gets the clock selection of LPUART. -* -* @param base Base address for current SIM instance. -* @param instance LPUART instance. -* @return Current selection. -*/ -clock_lpuart_src_t CLOCK_HAL_GetLpuartSrc(SIM_Type * base, - uint32_t instance); - -/*! -* @brief Set the clock selection of TPM. -* -* This function sets the clock selection of TPM. -* -* @param base Base address for current SIM instance. -* @param instance IP instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetTpmSrc(SIM_Type * base, - uint32_t instance, - clock_tpm_src_t setting) -{ - SIM_BWR_SOPT2_TPMSRC(base, setting); -} - -/*! -* @brief Get the clock selection of TPM. -* -* This function gets the clock selection of TPM. -* -* @param base Base address for current SIM instance. -* @param instance IP instance. -* @return Current selection. -*/ -static inline clock_tpm_src_t CLOCK_HAL_GetTpmSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_tpm_src_t)SIM_BRD_SOPT2_TPMSRC(base); -} - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} - -/*! - * @brief Select the clock source for FLEXIO. - * - * This function selects the clock source for FLEXIO. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetFlexioSrc(SIM_Type * base, - uint32_t instance, - clock_flexio_src_t setting) -{ - SIM_BWR_SOPT2_FLEXIOSRC(base, setting); -} - -/*! - * @brief Get the clock source of FLEXIO. - * - * This function gets the clock source of FLEXIO. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_flexio_src_t CLOCK_HAL_GetFlexioSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_flexio_src_t)SIM_BRD_SOPT2_FLEXIOSRC(base); -} - -/*! -* @brief Set the clock ERCLK32K output on selected pin. -* -* This function sets ERCLK32K output on selected pin. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetOsc32kOutSel(SIM_Type * base, - clock_osc32kout_sel_t setting) -{ - SIM_BWR_SOPT1_OSC32KOUT(base, setting); -} - -/*! -* @brief Get output status of ERCLK32K. -* -* This function gets the output status of ERCLK32K. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_osc32kout_sel_t CLOCK_HAL_GetOsc32kOutSel(SIM_Type * base) -{ - return (clock_osc32kout_sel_t)SIM_BRD_SOPT1_OSC32KOUT(base); -} - - -/*! -* @brief Set the clock selection of ERCLK32K. -* -* This function sets the clock selection of ERCLK32K. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! -* @brief Get the clock selection of ERCLK32K. -* -* This function gets the clock selection of ERCLK32K. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! -* @brief Set CLKOUTSEL selection. -* -* This function sets the selection of the clock to output on the CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! -* @brief Get CLKOUTSEL selection. -* -* This function gets the selection of the clock to output on the CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! -* @brief Set RTCCLKOUTSEL selection. -* -* This function sets the selection of the clock to output on the RTC_CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! -* @brief Get RTCCLKOUTSEL selection. -* -* This function gets the selection of the clock to output on the RTC_CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - - -/*! -* @brief Set the clock selection of COP. -* -* This function sets the clock selection of COP. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetCopSrc(SIM_Type * base, - clock_cop_src_t setting) -{ - SIM_BWR_COPC_COPCLKSEL(base, setting); -} - -/*! -* @brief Get the clock selection of COP. -* -* This function gets the clock selection of COP. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_cop_src_t CLOCK_HAL_GetCopSrc(SIM_Type * base) -{ - return (clock_cop_src_t)SIM_BRD_COPC_COPCLKSEL(base); -} - - -/*! -* @brief Set OUTDIV1. -* -* This function sets divide value OUTDIV1. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! -* @brief Get OUTDIV1. -* -* This function gets divide value OUTDIV1. -* -* @param base Base address for current SIM instance. -* @return Current divide value. -*/ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! -* @brief Set OUTDIV4. -* -* This function sets divide value OUTDIV4. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! -* @brief Get OUTDIV4. -* -* This function gets divide value OUTDIV4. -* -* @param base Base address for current SIM instance. -* @return Current divide value. -*/ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -/*! -* @brief Sets the ADCx alternate trigger enable setting. -* -* This function enables/disables the alternative conversion triggers for ADCx. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param enable Enable alternative conversion triggers for ADCx -* - true: Select alternative conversion trigger. -* - false: Select PDB trigger. -*/ -static inline void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - -} -/*! -* @brief Gets the ADCx alternate trigger enable setting. -* -* This function gets the ADCx alternate trigger enable setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return enabled True if ADCx alternate trigger is enabled -*/ - -static inline bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - - return retValue; -} - - -/*! -* @brief Sets the ADCx pre-trigger select setting. -* -* This function selects the ADCx pre-trigger source when the alternative -* triggers are enabled through ADCxALTTRGEN. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select pre-trigger select setting for ADCx -*/ -static inline void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - -} -/*! -* @brief Gets the ADCx pre-trigger select setting. -* -* This function gets the ADCx pre-trigger select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return select ADCx pre-trigger select setting -*/ -static inline sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - - return retValue; -} - -/*! -* @brief Sets the ADCx trigger select setting. -* -* This function selects the ADCx trigger source when alternative triggers -* are enabled through ADCxALTTRGEN. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select trigger select setting for ADCx -*/ -static inline void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - -} - -/*! -* @brief Gets the ADCx trigger select setting. -* -* This function gets the ADCx trigger select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return ADCx trigger select setting -*/ -static inline sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - - return retValue; -} - -/*! -* @brief Sets the ADCx trigger select setting in one function. -* -* This function sets ADC alternate trigger, pre-trigger mode and trigger mode. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param altTrigEn Alternative trigger enable or not. -* @param preTrigSel Pre-trigger mode. -* @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! -* @brief Sets the LPUARTx receive data source select setting. -* -* This function selects the source for the LPUARTx receive data. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @param select the source for the LPUARTx receive data -*/ -void SIM_HAL_SetLpuartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpuart_rxsrc_t select); - -/*! -* @brief Gets the LPUARTx receive data source select setting. -* -* This function gets the LPUARTx receive data source select setting. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* -* @return select UARTx receive data source select setting -*/ -sim_lpuart_rxsrc_t SIM_HAL_GetLpuartRxSrcMode(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the LPUARTx transmit data source select setting. -* -* This function selects the source for the LPUARTx transmit data. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @param select the source for the UARTx transmit data. -*/ -void SIM_HAL_SetLpuartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpuart_txsrc_t select); - -/*! -* @brief Gets the LPUARTx transmit data source select setting. -* -* This function gets the LPUARTx transmit data source select setting. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @return select UARTx transmit data source select setting. -*/ -sim_lpuart_txsrc_t SIM_HAL_GetLpuartTxSrcMode(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the LPUARTx Open Drain Enable setting. -* -* This function enables/disables the LPUARTx Open Drain. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @param enable Enable/disable LPUARTx Open Drain -* - True: Enable LPUARTx Open Drain -* - False: Disable LPUARTx Open Drain -*/ -void SIM_HAL_SetLpuartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable); - -/*! -* @brief Gets the LPUARTx Open Drain Enable setting. -* -* This function gets the LPUARTx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @return enabled True if LPUARTx Open Drain is enabled. -*/ -bool SIM_HAL_GetLpuartOpenDrainCmd(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the UARTx Open Drain Enable setting. -* -* This function enables/disables the UARTx Open Drain. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @param enable Enable/disable UARTx Open Drain -* - True: Enable UARTx Open Drain -* - False: Disable UARTx Open Drain -*/ -static inline void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - // Only support UART2 - assert (2 == instance); - SIM_BWR_SOPT5_UART2ODE(base, enable ? 1 : 0); -} - -/*! -* @brief Gets the UARTx Open Drain Enable setting. -* -* This function gets the UARTx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @return enabled True if UARTx Open Drain is enabled. -*/ -static inline bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, - uint32_t instance) -{ - // Only support UART2 - assert (2 == instance); - return (bool)SIM_BRD_SOPT5_UART2ODE(base); -} - -/*! -* @brief Sets the Timer/PWM x channel y input capture source select setting. -* -* This function selects the Timer/PWM x channel y input capture source. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @param select Timer/PWM x channel y input capture source -*/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select); - -/*! -* @brief Gets the Timer/PWM x channel y input capture source select setting. -* -* This function gets the Timer/PWM x channel y input capture source select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel Tpm channel y -* @return select Timer/PWM x channel y input capture source select setting -*/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! -* @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Sub-Family ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Sub-Family ID -*/ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} - -/*! -* @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Series ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Series ID -*/ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type * base) -{ - return SIM_BRD_SDID_SERIESID(base); -} - -/*! -* @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Fam ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Fam ID -*/ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! -* @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Pincount ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Pincount ID -*/ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! -* @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Revision ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Revision ID -*/ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! -* @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function gets the program flash size in the Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @return size Program flash Size -*/ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! -* @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function sets the Flash Doze in the Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @param setting Flash Doze setting -*/ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! -* @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function gets the Flash Doze in the Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @return setting Flash Doze setting -*/ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! -* @brief Sets the Flash disable setting. -* -* This function sets the Flash disable setting in the -* Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @param disable Flash disable setting -*/ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! -* @brief Gets the Flash disable setting. -* -* This function gets the Flash disable setting in the -* Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @return setting Flash disable setting -*/ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! -* @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function gets the Flash maximum block 0 in Flash Configuration Register 2. -* -* @param base Base address for current SIM instance. -* @return address Flash maximum block 0 address -*/ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! -* @brief Sets the Timer/PWM x external clock pin select setting. -* -* This function selects the source of the Timer/PWM x external clock pin select. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select Timer/PWM x external clock pin select -* - 0: Timer/PWM x external clock driven by the TPM_CLKIN0 pin. -* - 1: Timer/PWM x external clock driven by the TPM_CLKIN1 pin. -*/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select); - -/*! -* @brief Gets the Timer/PWM x external clock pin select setting. -* -* This function gets the Timer/PWM x external clock pin select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return select Timer/PWM x external clock pin select setting -*/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance); - - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_SIM_HAL_MKL17Z644_H__*/ -/******************************************************************************* -* EOF -******************************************************************************/ diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL24Z4/fsl_sim_hal_MKL24Z4.c b/KSDK_1.2.0/platform/hal/src/sim/MKL24Z4/fsl_sim_hal_MKL24Z4.c deleted file mode 100755 index 4598b07..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL24Z4/fsl_sim_hal_MKL24Z4.c +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = 0U; - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable settingg - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, uint32_t instance, sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue =(sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - - if (altTrigEn) - { - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartOpenDrainCmd - * Description : Set UARTx Open Drain Enable setting - * This function will enable/disable the UARTx Open Drain. - * - *END**************************************************************************/ -void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 1: - SIM_BWR_SOPT5_UART1ODE(base, enable ? 1 : 0); - break; - case 2: - SIM_BWR_SOPT5_UART2ODE(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartOpenDrainCmd - * Description : Get UARTx Open Drain Enable setting - * This function will get UARTx Open Drain Enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 1: - retValue = SIM_BRD_SOPT5_UART1ODE(base); - break; - case 2: - retValue = SIM_BRD_SOPT5_UART2ODE(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmExternalClkPinSelMode - * Description : Set Timer/PWM x external clock pin select setting - * This function will select the source of Timer/PWM x external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_TPM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_TPM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_TPM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetTpmExternalClkPinSelMode - * Description : Get Timer/PWM x external clock pin select setting - * This function will get Timer/PWM x external clock pin select setting. - * - *END**************************************************************************/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance) -{ - sim_tpm_clk_sel_t retValue = (sim_tpm_clk_sel_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM0CLKSEL(base); - break; - case 1: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM1CLKSEL(base); - break; - case 2: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmChSrcMode - * Description : Timer/PWM x channel y input capture source select setting - * This function will select Timer/PWM x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - SIM_BWR_SOPT4_TPM1CH0SRC(base, select); - break; - case 2: - SIM_BWR_SOPT4_TPM2CH0SRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetTpmChSrcMode - * Description : Get Timer/PWM x channel y input capture source select setting - * This function will get Timer/PWM x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_tpm_ch_src_t retValue = (sim_tpm_ch_src_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM1CH0SRC(base); - break; - case 2: - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM2CH0SRC(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL24Z4/fsl_sim_hal_MKL24Z4.h b/KSDK_1.2.0/platform/hal/src/sim/MKL24Z4/fsl_sim_hal_MKL24Z4.h deleted file mode 100644 index 7fc36bd..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL24Z4/fsl_sim_hal_MKL24Z4.h +++ /dev/null @@ -1,1298 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_KL24Z4_H__) -#define __FSL_SIM_HAL_KL24Z4_H__ - -/*! @addtogroup sim_hal*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - - /*! @brief COP clock source select */ -typedef enum _clock_cop_src_t -{ - kClockCopSrcLpoClk, /* LPO */ - kClockCopSrcAltClk, /* Altnative clock, for KL24Z4 it is Bus clock. */ -} clock_cop_src_t; - -/*! @brief TPM clock source select */ -typedef enum _clock_tpm_src -{ - kClockTpmSrcNone, /* clock disabled */ - kClockTpmSrcPllFllSel, /* clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTpmSrcOsc0erClk, /* OSCERCLK clock */ - kClockTpmSrcMcgIrClk /* MCGIR clock */ -} clock_tpm_src_t; - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /* MCG out clock */ - kClockLptmrSrcLpoClk, /* LPO clock */ - kClockLptmrSrcEr32kClk, /* ERCLK32K clock */ - kClockLptmrSrcOsc0erClk, /* OSCERCLK clock */ -} clock_lptmr_src_t; - -/*! @brief UART0 clock source select */ -typedef enum _clock_lpsci_src -{ - kClockLpsciSrcNone, /* clock disabled */ - kClockLpsciSrcPllFllSel, /* clock as selected by SOPT2[PLLFLLSEL]. */ - kClockLpsciSrcOsc0erClk, /* OSCERCLK clock */ - kClockLpsciSrcMcgIrClk /* MCGIR clock */ -} clock_lpsci_src_t; - -/*! @brief USB clock source select */ -#if FSL_FEATURE_SOC_USB_COUNT -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /* USB CLKIN Clock */ - kClockUsbfsSrcPllFllSel /* clock as selected by SOPT2[PLLFLLSEL] */ -} clock_usbfs_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll, /* Fll clock */ - kClockPllFllSelPll /* Pll0 clock */ -} clock_pllfll_sel_t; - -/*! @brief SIM external reference clock source select (OSC32KSEL) */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /* OSC 32k clock */ - kClockEr32kSrcReserved = 1U, /* Reserved */ - kClockEr32kSrcRtc = 2U, /* RTC 32k clock */ - kClockEr32kSrcLpo = 3U /* LPO clock */ -} clock_er32k_src_t; - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutReserved = 0U, /* Reserved */ - kClockClkoutReserved1 = 1U, /* Reserved */ - kClockClkoutBusClk = 2U, /* Bus clock */ - kClockClkoutLpoClk = 3U, /* LPO clock */ - kClockClkoutMcgIrClk = 4U, /* MCG ir clock */ - kClockClkoutReserved2 = 5U, /* Reserved */ - kClockClkoutOsc0erClk = 6U, /* OSC0ER clock */ - kClockClkoutReserved3 = 7U -} clock_clkout_src_t; - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /* 1Hz clock */ - kClockRtcoutSrc32kHz /* 32KHz clock */ -} clock_rtcout_src_t; - -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -#if FSL_FEATURE_SOC_USB_COUNT -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /* regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /* regulator in standby during Stop modes */ -} sim_usbsstby_mode_t; - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /* regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /* regulator in standby during VLPR and VLPW modes */ -} sim_usbvstby_mode_t; -#endif - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /* Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /* Pre-trigger B selected for ADCx */ -} sim_adc_pretrg_sel_t; - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /* External trigger */ - kSimAdcTrgSelComp0 = 1U, /* CMP0 output */ - kSimAdcTrgSelReserved = 2U, /* Reserved */ - kSimAdcTrgSelReserved1 = 3U, /* Reserved */ - kSimAdcTrgSelPit0 = 4U, /* PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /* PIT trigger 1 */ - kSimAdcTrgSelReserved2 = 6U, /* Reserved */ - kSimAdcTrgSelReserved3 = 7U, /* Reserved */ - kSimAdcTrgSelTpm0 = 8U, /* TPM0 overflow */ - kSimAdcTrgSelTpm1 = 9U, /* TPM1 overflow */ - kSimAdcTrgSelTpm2 = 10U, /* TPM2 overflow */ - kSimAdcTrgSelReserved4 = 11U, /* Reserved */ - kSimAdcTrgSelRtcAlarm = 12U, /* RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /* RTC seconds */ - kSimAdcTrgSelLptimer = 14U, /* Low-power timer trigger */ - kSimAdcTrgSelReserved5 = 15U /* Reserved */ -} sim_adc_trg_sel_t; - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /* UARTx_RX Pin */ - kSimUartRxsrcCmp0, /* CMP0 */ -} sim_uart_rxsrc_t; - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /* UARTx_TX Pin */ - kSimUartTxsrcTpm0, /* UARTx_TX pin modulated with TPM1 channel 0 output */ - kSimUartTxsrcTpm1, /* UARTx_TX pin modulated with TPM2 channel 0 output */ - kSimUartTxsrcReserved /* Reserved */ -} sim_uart_txsrc_t; - -/*! @brief SIM LPSCI receive data source select */ -typedef enum _sim_lpsci_rxsrc -{ - kSimLpsciRxsrcPin, /* LPSCIx_RX Pin */ - kSimLpsciRxsrcCmp0, /* CMP0 */ -} sim_lpsci_rxsrc_t; - -/*! @brief SIM LPSCI transmit data source select */ -typedef enum _sim_lpsci_txsrc -{ - kSimLpsciTxsrcPin, /* LPSCIx_TX Pin */ - kSimLpsciTxsrcTpm0, /* LPSCIx_TX pin modulated with TPM1 channel 0 output */ - kSimLpsciTxsrcTpm1, /* LPSCIx_TX pin modulated with TPM2 channel 0 output */ - kSimLpsciTxsrcReserved /* Reserved */ -} sim_lpsci_txsrc_t; - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /* Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /* Timer/PWM TPM_CLKIN1 pin. */ -} sim_tpm_clk_sel_t; - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /* TPMx_CH0 signal */ - kSimTpmChSrc1, /* CMP0 output */ - kSimTpmChSrc2, /* Reserved */ - kSimTpmChSrc3 /* USB start of frame pulse */ -} sim_tpm_ch_src_t; - -/* SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -typedef enum _sim_clock_gate_name -{ - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateLpsci0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), - kSimClockGateCmp0 = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(4U, 22U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(4U, 23U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGateTsi0 = FSL_SIM_SCGC_BIT(5U, 5U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateTpm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateTpm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateTpm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(6U, 31U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 8U) -} sim_clock_gate_name_t; - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! @name IP related clock feature APIs*/ -/*@{*/ - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ - #if FSL_FEATURE_SOC_USB_COUNT -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} -#endif - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTpmSrc(SIM_Type * base, - uint32_t instance, - clock_tpm_src_t setting) -{ - SIM_BWR_SOPT2_TPMSRC(base, setting); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_HAL_GetTpmSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_tpm_src_t)SIM_BRD_SOPT2_TPMSRC(base); -} - -/*! - * @brief Set the LPSCI clock source selection. - * - * This function sets the LPSCI clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetLpsciSrc(SIM_Type * base, - uint32_t instance, - clock_lpsci_src_t setting) -{ - SIM_BWR_SOPT2_UART0SRC(base, setting); -} - -/*! - * @brief Get the LPSCI clock source selection. - * - * This function gets the LPSCI clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_lpsci_src_t CLOCK_HAL_GetLpsciSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_lpsci_src_t)SIM_BRD_SOPT2_UART0SRC(base); -} -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - - * This function sets the setting for all clock out dividers at the same time. - - * - - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -#if FSL_FEATURE_SOC_USB_COUNT -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -static inline void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - SIM_BWR_SOPT5_UART1RXSRC(base, select); -} - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -static inline sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); -} - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -static inline void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - SIM_BWR_SOPT5_UART1TXSRC(base, select); -} - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -static inline sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); -} - -/*! - * @brief Sets the LPSCIx receive data source select setting. - * - * This function selects the source for the LPSCIx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the LPSCIx receive data - */ -static inline void SIM_HAL_SetLpsciRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpsci_rxsrc_t select) -{ - SIM_BWR_SOPT5_UART0RXSRC(base, select); -} - -/*! - * @brief Gets the LPSCIx receive data source select setting. - * - * This function gets the LPSCIx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select LPSCIx receive data source select setting - */ -static inline sim_lpsci_rxsrc_t SIM_HAL_GetLpsciRxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_lpsci_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); -} - -/*! - * @brief Sets the LPSCIx transmit data source select setting. - * - * This function selects the source for the LPSCIx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the LPSCIx transmit data - */ -static inline void SIM_HAL_SetLpsciTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpsci_txsrc_t select) -{ - SIM_BWR_SOPT5_UART0TXSRC(base, select); -} - -/*! - * @brief Gets the LPSCIx transmit data source select setting. - * - * This function gets the LPSCIx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select LPSCIx transmit data source select setting - */ -static inline sim_lpsci_txsrc_t SIM_HAL_GetLpsciTxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_lpsci_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); -} - -#if FSL_FEATURE_SIM_OPT_HAS_ODE - -/*! -* @brief Sets the UARTx Open Drain Enable setting. - - -* -* This function enables/disables the UARTx Open Drain. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @param enable Enable/disable UARTx Open Drain - - -* - True: Enable UARTx Open Drain -* - False: Disable UARTx Open Drain -*/ -void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable); - -/*! -* @brief Gets the UARTx Open Drain Enable setting. -* -* This function gets the UARTx Open Drain Enable setting. - - -* -* @param base Register base address of SIM. -* @param instance UART instance. -*/ -bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the LPSCIx Open Drain Enable setting. -* -* This function enables/disables the LPSCIx Open Drain. -* -* @param base Register base address of SIM. -* @param instance LPSCI instance. -* @param enable Enable/disable LPSCIx Open Drain -* - True: Enable LPSCIx Open Drain -* - False: Disable LPSCIx Open Drain -*/ -static inline void SIM_HAL_SetLpsciOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - SIM_BWR_SOPT5_UART0ODE(base, enable); -} - -/*! -* @brief Gets the LPSCIx Open Drain Enable setting. -* -* This function gets the LPSCIx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance LPSCI instance. -* @return enabled True if LPSCIx Open Drain is enabled. -*/ -static inline bool SIM_HAL_GetLpsciOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - return (bool)SIM_BRD_SOPT5_UART0ODE(base); -} -#endif - -#if FSL_FEATURE_SIM_OPT_HAS_TPM - -/*! -* @brief Sets the Timer/PWM x external clock pin select setting. -* -* This function selects the source of the Timer/PWM x external clock pin select. - - -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select Timer/PWM x external clock pin select -*/ - -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select); - -/*! -* @brief Gets the Timer/PWM x external clock pin select setting. -* -* This function gets the Timer/PWM x external clock pin select setting. - - -* -* @param base Base address for current SIM instance. -* @param instance device instance. -*/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the Timer/PWM x channel y input capture source select setting. -* -* This function selects the Timer/PWM x channel y input capture source. - - -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @param select Timer/PWM x channel y input capture source -*/ - -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select); - -/*! -* @brief Gets the Timer/PWM x channel y input capture source select setting. -* -* This function gets the Timer/PWM x channel y input capture source. - - -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -*/ - -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); -#endif - -/*! - * @brief Gets the Kinetis Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Family ID in the System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Family ID - */ -static inline uint32_t SIM_HAL_GetFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Sub-Family ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Sub-Family ID - */ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} - -/*! - * @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Series ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Series ID - */ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type * base) -{ - return SIM_BRD_SDID_SERIESID(base); -} - -/*! - * @brief Gets the Kinetis SramSize in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis SramSize in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis SramSize - */ -static inline uint32_t SIM_HAL_GetSramSize(SIM_Type * base) -{ - return SIM_BRD_SDID_SRAMSIZE(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the Kinetis Die ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Die ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Die ID - */ -static inline uint32_t SIM_HAL_GetDieId(SIM_Type * base) -{ - return SIM_BRD_SDID_DIEID(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_SIM_HAL_KL24Z4_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL25Z4/fsl_sim_hal_MKL25Z4.c b/KSDK_1.2.0/platform/hal/src/sim/MKL25Z4/fsl_sim_hal_MKL25Z4.c deleted file mode 100755 index 4598b07..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL25Z4/fsl_sim_hal_MKL25Z4.c +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = 0U; - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable settingg - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, uint32_t instance, sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue =(sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - - if (altTrigEn) - { - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartOpenDrainCmd - * Description : Set UARTx Open Drain Enable setting - * This function will enable/disable the UARTx Open Drain. - * - *END**************************************************************************/ -void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 1: - SIM_BWR_SOPT5_UART1ODE(base, enable ? 1 : 0); - break; - case 2: - SIM_BWR_SOPT5_UART2ODE(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartOpenDrainCmd - * Description : Get UARTx Open Drain Enable setting - * This function will get UARTx Open Drain Enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 1: - retValue = SIM_BRD_SOPT5_UART1ODE(base); - break; - case 2: - retValue = SIM_BRD_SOPT5_UART2ODE(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmExternalClkPinSelMode - * Description : Set Timer/PWM x external clock pin select setting - * This function will select the source of Timer/PWM x external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_TPM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_TPM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_TPM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetTpmExternalClkPinSelMode - * Description : Get Timer/PWM x external clock pin select setting - * This function will get Timer/PWM x external clock pin select setting. - * - *END**************************************************************************/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance) -{ - sim_tpm_clk_sel_t retValue = (sim_tpm_clk_sel_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM0CLKSEL(base); - break; - case 1: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM1CLKSEL(base); - break; - case 2: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmChSrcMode - * Description : Timer/PWM x channel y input capture source select setting - * This function will select Timer/PWM x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - SIM_BWR_SOPT4_TPM1CH0SRC(base, select); - break; - case 2: - SIM_BWR_SOPT4_TPM2CH0SRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetTpmChSrcMode - * Description : Get Timer/PWM x channel y input capture source select setting - * This function will get Timer/PWM x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_tpm_ch_src_t retValue = (sim_tpm_ch_src_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM1CH0SRC(base); - break; - case 2: - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM2CH0SRC(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL25Z4/fsl_sim_hal_MKL25Z4.h b/KSDK_1.2.0/platform/hal/src/sim/MKL25Z4/fsl_sim_hal_MKL25Z4.h deleted file mode 100644 index 5a5cfec..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL25Z4/fsl_sim_hal_MKL25Z4.h +++ /dev/null @@ -1,1298 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_KL25Z4_H__) -#define __FSL_SIM_HAL_KL25Z4_H__ - -/*! @addtogroup sim_hal*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - - /*! @brief COP clock source select */ -typedef enum _clock_cop_src_t -{ - kClockCopSrcLpoClk, /* LPO */ - kClockCopSrcAltClk, /* Altnative clock, for KL25Z4 it is Bus clock. */ -} clock_cop_src_t; - -/*! @brief TPM clock source select */ -typedef enum _clock_tpm_src -{ - kClockTpmSrcNone, /* clock disabled */ - kClockTpmSrcPllFllSel, /* clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTpmSrcOsc0erClk, /* OSCERCLK clock */ - kClockTpmSrcMcgIrClk /* MCGIR clock */ -} clock_tpm_src_t; - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /* MCG out clock */ - kClockLptmrSrcLpoClk, /* LPO clock */ - kClockLptmrSrcEr32kClk, /* ERCLK32K clock */ - kClockLptmrSrcOsc0erClk, /* OSCERCLK clock */ -} clock_lptmr_src_t; - -/*! @brief UART0 clock source select */ -typedef enum _clock_lpsci_src -{ - kClockLpsciSrcNone, /* clock disabled */ - kClockLpsciSrcPllFllSel, /* clock as selected by SOPT2[PLLFLLSEL]. */ - kClockLpsciSrcOsc0erClk, /* OSCERCLK clock */ - kClockLpsciSrcMcgIrClk /* MCGIR clock */ -} clock_lpsci_src_t; - -/*! @brief USB clock source select */ -#if FSL_FEATURE_SOC_USB_COUNT -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /* USB CLKIN Clock */ - kClockUsbfsSrcPllFllSel /* clock as selected by SOPT2[PLLFLLSEL] */ -} clock_usbfs_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll, /* Fll clock */ - kClockPllFllSelPll /* Pll0 clock */ -} clock_pllfll_sel_t; - -/*! @brief SIM external reference clock source select (OSC32KSEL) */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /* OSC 32k clock */ - kClockEr32kSrcReserved = 1U, /* Reserved */ - kClockEr32kSrcRtc = 2U, /* RTC 32k clock */ - kClockEr32kSrcLpo = 3U /* LPO clock */ -} clock_er32k_src_t; - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutReserved = 0U, /* Reserved */ - kClockClkoutReserved1 = 1U, /* Reserved */ - kClockClkoutBusClk = 2U, /* Bus clock */ - kClockClkoutLpoClk = 3U, /* LPO clock */ - kClockClkoutMcgIrClk = 4U, /* MCG ir clock */ - kClockClkoutReserved2 = 5U, /* Reserved */ - kClockClkoutOsc0erClk = 6U, /* OSC0ER clock */ - kClockClkoutReserved3 = 7U -} clock_clkout_src_t; - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /* 1Hz clock */ - kClockRtcoutSrc32kHz /* 32KHz clock */ -} clock_rtcout_src_t; - -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -#if FSL_FEATURE_SOC_USB_COUNT -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /* regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /* regulator in standby during Stop modes */ -} sim_usbsstby_mode_t; - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /* regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /* regulator in standby during VLPR and VLPW modes */ -} sim_usbvstby_mode_t; -#endif - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /* Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /* Pre-trigger B selected for ADCx */ -} sim_adc_pretrg_sel_t; - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /* External trigger */ - kSimAdcTrgSelComp0 = 1U, /* CMP0 output */ - kSimAdcTrgSelReserved = 2U, /* Reserved */ - kSimAdcTrgSelReserved1 = 3U, /* Reserved */ - kSimAdcTrgSelPit0 = 4U, /* PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /* PIT trigger 1 */ - kSimAdcTrgSelReserved2 = 6U, /* Reserved */ - kSimAdcTrgSelReserved3 = 7U, /* Reserved */ - kSimAdcTrgSelTpm0 = 8U, /* TPM0 overflow */ - kSimAdcTrgSelTpm1 = 9U, /* TPM1 overflow */ - kSimAdcTrgSelTpm2 = 10U, /* TPM2 overflow */ - kSimAdcTrgSelReserved4 = 11U, /* Reserved */ - kSimAdcTrgSelRtcAlarm = 12U, /* RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /* RTC seconds */ - kSimAdcTrgSelLptimer = 14U, /* Low-power timer trigger */ - kSimAdcTrgSelReserved5 = 15U /* Reserved */ -} sim_adc_trg_sel_t; - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /* UARTx_RX Pin */ - kSimUartRxsrcCmp0, /* CMP0 */ -} sim_uart_rxsrc_t; - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /* UARTx_TX Pin */ - kSimUartTxsrcTpm0, /* UARTx_TX pin modulated with TPM1 channel 0 output */ - kSimUartTxsrcTpm1, /* UARTx_TX pin modulated with TPM2 channel 0 output */ - kSimUartTxsrcReserved /* Reserved */ -} sim_uart_txsrc_t; - -/*! @brief SIM LPSCI receive data source select */ -typedef enum _sim_lpsci_rxsrc -{ - kSimLpsciRxsrcPin, /* LPSCIx_RX Pin */ - kSimLpsciRxsrcCmp0, /* CMP0 */ -} sim_lpsci_rxsrc_t; - -/*! @brief SIM LPSCI transmit data source select */ -typedef enum _sim_lpsci_txsrc -{ - kSimLpsciTxsrcPin, /* LPSCIx_TX Pin */ - kSimLpsciTxsrcTpm0, /* LPSCIx_TX pin modulated with TPM1 channel 0 output */ - kSimLpsciTxsrcTpm1, /* LPSCIx_TX pin modulated with TPM2 channel 0 output */ - kSimLpsciTxsrcReserved /* Reserved */ -} sim_lpsci_txsrc_t; - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /* Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /* Timer/PWM TPM_CLKIN1 pin. */ -} sim_tpm_clk_sel_t; - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /* TPMx_CH0 signal */ - kSimTpmChSrc1, /* CMP0 output */ - kSimTpmChSrc2, /* Reserved */ - kSimTpmChSrc3 /* USB start of frame pulse */ -} sim_tpm_ch_src_t; - -/* SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -typedef enum _sim_clock_gate_name -{ - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateLpsci0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), - kSimClockGateCmp0 = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(4U, 22U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(4U, 23U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGateTsi0 = FSL_SIM_SCGC_BIT(5U, 5U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateTpm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateTpm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateTpm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(6U, 31U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 8U) -} sim_clock_gate_name_t; - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! @name IP related clock feature APIs*/ -/*@{*/ - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ - #if FSL_FEATURE_SOC_USB_COUNT -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} -#endif - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTpmSrc(SIM_Type * base, - uint32_t instance, - clock_tpm_src_t setting) -{ - SIM_BWR_SOPT2_TPMSRC(base, setting); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_HAL_GetTpmSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_tpm_src_t)SIM_BRD_SOPT2_TPMSRC(base); -} - -/*! - * @brief Set the LPSCI clock source selection. - * - * This function sets the LPSCI clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetLpsciSrc(SIM_Type * base, - uint32_t instance, - clock_lpsci_src_t setting) -{ - SIM_BWR_SOPT2_UART0SRC(base, setting); -} - -/*! - * @brief Get the LPSCI clock source selection. - * - * This function gets the LPSCI clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_lpsci_src_t CLOCK_HAL_GetLpsciSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_lpsci_src_t)SIM_BRD_SOPT2_UART0SRC(base); -} -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - - * This function sets the setting for all clock out dividers at the same time. - - * - - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -#if FSL_FEATURE_SOC_USB_COUNT -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -static inline void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - SIM_BWR_SOPT5_UART1RXSRC(base, select); -} - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -static inline sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); -} - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -static inline void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - SIM_BWR_SOPT5_UART1TXSRC(base, select); -} - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -static inline sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); -} - -/*! - * @brief Sets the LPSCIx receive data source select setting. - * - * This function selects the source for the LPSCIx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the LPSCIx receive data - */ -static inline void SIM_HAL_SetLpsciRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpsci_rxsrc_t select) -{ - SIM_BWR_SOPT5_UART0RXSRC(base, select); -} - -/*! - * @brief Gets the LPSCIx receive data source select setting. - * - * This function gets the LPSCIx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select LPSCIx receive data source select setting - */ -static inline sim_lpsci_rxsrc_t SIM_HAL_GetLpsciRxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_lpsci_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); -} - -/*! - * @brief Sets the LPSCIx transmit data source select setting. - * - * This function selects the source for the LPSCIx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the LPSCIx transmit data - */ -static inline void SIM_HAL_SetLpsciTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpsci_txsrc_t select) -{ - SIM_BWR_SOPT5_UART0TXSRC(base, select); -} - -/*! - * @brief Gets the LPSCIx transmit data source select setting. - * - * This function gets the LPSCIx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select LPSCIx transmit data source select setting - */ -static inline sim_lpsci_txsrc_t SIM_HAL_GetLpsciTxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_lpsci_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); -} - -#if FSL_FEATURE_SIM_OPT_HAS_ODE - -/*! -* @brief Sets the UARTx Open Drain Enable setting. - - -* -* This function enables/disables the UARTx Open Drain. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @param enable Enable/disable UARTx Open Drain - - -* - True: Enable UARTx Open Drain -* - False: Disable UARTx Open Drain -*/ -void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable); - -/*! -* @brief Gets the UARTx Open Drain Enable setting. -* -* This function gets the UARTx Open Drain Enable setting. - - -* -* @param base Register base address of SIM. -* @param instance UART instance. -*/ -bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the LPSCIx Open Drain Enable setting. -* -* This function enables/disables the LPSCIx Open Drain. -* -* @param base Register base address of SIM. -* @param instance LPSCI instance. -* @param enable Enable/disable LPSCIx Open Drain -* - True: Enable LPSCIx Open Drain -* - False: Disable LPSCIx Open Drain -*/ -static inline void SIM_HAL_SetLpsciOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - SIM_BWR_SOPT5_UART0ODE(base, enable); -} - -/*! -* @brief Gets the LPSCIx Open Drain Enable setting. -* -* This function gets the LPSCIx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance LPSCI instance. -* @return enabled True if LPSCIx Open Drain is enabled. -*/ -static inline bool SIM_HAL_GetLpsciOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - return (bool)SIM_BRD_SOPT5_UART0ODE(base); -} -#endif - -#if FSL_FEATURE_SIM_OPT_HAS_TPM - -/*! -* @brief Sets the Timer/PWM x external clock pin select setting. -* -* This function selects the source of the Timer/PWM x external clock pin select. - - -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select Timer/PWM x external clock pin select -*/ - -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select); - -/*! -* @brief Gets the Timer/PWM x external clock pin select setting. -* -* This function gets the Timer/PWM x external clock pin select setting. - - -* -* @param base Base address for current SIM instance. -* @param instance device instance. -*/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the Timer/PWM x channel y input capture source select setting. -* -* This function selects the Timer/PWM x channel y input capture source. - - -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @param select Timer/PWM x channel y input capture source -*/ - -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select); - -/*! -* @brief Gets the Timer/PWM x channel y input capture source select setting. -* -* This function gets the Timer/PWM x channel y input capture source. - - -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -*/ - -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); -#endif - -/*! - * @brief Gets the Kinetis Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Family ID in the System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Family ID - */ -static inline uint32_t SIM_HAL_GetFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Sub-Family ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Sub-Family ID - */ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} - -/*! - * @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Series ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Series ID - */ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type * base) -{ - return SIM_BRD_SDID_SERIESID(base); -} - -/*! - * @brief Gets the Kinetis SramSize in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis SramSize in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis SramSize - */ -static inline uint32_t SIM_HAL_GetSramSize(SIM_Type * base) -{ - return SIM_BRD_SDID_SRAMSIZE(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the Kinetis Die ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Die ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Die ID - */ -static inline uint32_t SIM_HAL_GetDieId(SIM_Type * base) -{ - return SIM_BRD_SDID_DIEID(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_SIM_HAL_KL25Z4_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL26Z4/fsl_sim_hal_MKL26Z4.c b/KSDK_1.2.0/platform/hal/src/sim/MKL26Z4/fsl_sim_hal_MKL26Z4.c deleted file mode 100755 index 11e5e13..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL26Z4/fsl_sim_hal_MKL26Z4.c +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = 0U; - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable settingg - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, uint32_t instance, sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue =(sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - - if (altTrigEn) - { - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartOpenDrainCmd - * Description : Set UARTx Open Drain Enable setting - * This function will enable/disable the UARTx Open Drain. - * - *END**************************************************************************/ -void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 1: - SIM_BWR_SOPT5_UART1ODE(base, enable ? 1 : 0); - break; - case 2: - SIM_BWR_SOPT5_UART2ODE(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartOpenDrainCmd - * Description : Get UARTx Open Drain Enable setting - * This function will get UARTx Open Drain Enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 1: - retValue = SIM_BRD_SOPT5_UART1ODE(base); - break; - case 2: - retValue = SIM_BRD_SOPT5_UART2ODE(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmExternalClkPinSelMode - * Description : Set Timer/PWM x external clock pin select setting - * This function will select the source of Timer/PWM x external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_TPM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_TPM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_TPM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetTpmExternalClkPinSelMode - * Description : Get Timer/PWM x external clock pin select setting - * This function will get Timer/PWM x external clock pin select setting. - * - *END**************************************************************************/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance) -{ - sim_tpm_clk_sel_t retValue = (sim_tpm_clk_sel_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM0CLKSEL(base); - break; - case 1: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM1CLKSEL(base); - break; - case 2: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmChSrcMode - * Description : Timer/PWM x channel y input capture source select setting - * This function will select Timer/PWM x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - SIM_BWR_SOPT4_TPM1CH0SRC(base, select); - break; - case 2: - SIM_BWR_SOPT4_TPM2CH0SRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetTpmChSrcMode - * Description : Get Timer/PWM x channel y input capture source select setting - * This function will get Timer/PWM x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_tpm_ch_src_t retValue = (sim_tpm_ch_src_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM1CH0SRC(base); - break; - case 2: - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM2CH0SRC(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL26Z4/fsl_sim_hal_MKL26Z4.h b/KSDK_1.2.0/platform/hal/src/sim/MKL26Z4/fsl_sim_hal_MKL26Z4.h deleted file mode 100644 index 2061b9d..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL26Z4/fsl_sim_hal_MKL26Z4.h +++ /dev/null @@ -1,1397 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_KL26Z4_H__) -#define __FSL_SIM_HAL_KL26Z4_H__ - - -/*! - * @addtogroup sim_hal_kl26z4 - * @{ - */ -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - - /*! @brief COP clock source select */ -typedef enum _clock_cop_src_t -{ - kClockCopSrcLpoClk, /*!< LPO */ - kClockCopSrcAltClk, /*!< Alternative clock, for KL26Z4 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_cop_src_kl26z4_t; -#else -} clock_cop_src_t; -#endif - -/*! @brief TPM clock source select */ -typedef enum _clock_tpm_src -{ - kClockTpmSrcNone, /*!< clock disabled */ - kClockTpmSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTpmSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTpmSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tpm_src_kl26z4_t; -#else -} clock_tpm_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG out clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk, /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_kl26z4_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief UART0 clock source select */ -typedef enum _clock_lpsci_src -{ - kClockLpsciSrcNone, /*!< clock disabled */ - kClockLpsciSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockLpsciSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockLpsciSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lpsci_src_kl26z4_t; -#else -} clock_lpsci_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB clock source select */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< USB CLKIN Clock */ - kClockUsbfsSrcPllFllSel /*!< clock as selected by SOPT2[PLLFLLSEL] */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_kl26z4_t; -#else -} clock_usbfs_src_t; -#endif -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_kl26z4_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll, /*!< Fll clock */ - kClockPllFllSelPll /*!< Pll0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_kl26z4_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL) */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC 32k clock */ - kClockEr32kSrcReserved = 1U, /*!< Reserved */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock */ - kClockEr32kSrcLpo = 3U /*!< LPO clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_kl26z4_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutReserved = 0U, /*!< Reserved */ - kClockClkoutReserved1 = 1U, /*!< Reserved */ - kClockClkoutBusClk = 2U, /*!< Bus clock */ - kClockClkoutLpoClk = 3U, /*!< LPO clock */ - kClockClkoutMcgIrClk = 4U, /*!< MCG ir clock */ - kClockClkoutReserved2 = 5U, /*!< Reserved */ - kClockClkoutOsc0erClk = 6U, /*!< OSC0ER clock */ - kClockClkoutReserved3 = 7U /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_kl26z4_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz /*!< 32KHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_kl26z4_t; -#else -} clock_rtcout_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_kl26z4_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_kl26z4_t; -#else -} sim_usbvstby_mode_t; -#endif -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_kl26z4_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelComp0 = 1U, /*!< CMP0 output */ - kSimAdcTrgSelReserved = 2U, /*!< Reserved */ - kSimAdcTrgSelReserved1 = 3U, /*!< Reserved */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelReserved2 = 6U, /*!< Reserved */ - kSimAdcTrgSelReserved3 = 7U, /*!< Reserved */ - kSimAdcTrgSelTpm0 = 8U, /*!< TPM0 overflow */ - kSimAdcTrgSelTpm1 = 9U, /*!< TPM1 overflow */ - kSimAdcTrgSelTpm2 = 10U, /*!< TPM2 overflow */ - kSimAdcTrgSelReserved4 = 11U, /*!< Reserved */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U, /*!< Low-power timer trigger */ - kSimAdcTrgSelReserved5 = 15U /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_kl26z4_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_kl26z4_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcTpm1, /*!< UARTx_TX pin modulated with TPM1 channel 0 output */ - kSimUartTxsrcTpm2, /*!< UARTx_TX pin modulated with TPM2 channel 0 output */ - kSimUartTxsrcReserved /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_kl26z4_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM LPSCI receive data source select */ -typedef enum _sim_lpsci_rxsrc -{ - kSimLpsciRxsrcPin, /*!< LPSCIx_RX Pin */ - kSimLpsciRxsrcCmp0, /*!< CMP0 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpsci_rxsrc_kl26z4_t; -#else -} sim_lpsci_rxsrc_t; -#endif - -/*! @brief SIM LPSCI transmit data source select */ -typedef enum _sim_lpsci_txsrc -{ - kSimLpsciTxsrcPin, /*!< LPSCIx_TX Pin */ - kSimLpsciTxsrcTpm1, /*!< LPSCIx_TX pin modulated with TPM1 channel 0 output */ - kSimLpsciTxsrcTpm2, /*!< LPSCIx_TX pin modulated with TPM2 channel 0 output */ - kSimLpsciTxsrcReserved /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpsci_txsrc_kl26z4_t; -#else -} sim_lpsci_txsrc_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_kl26z4_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1, /*!< CMP0 output */ - kSimTpmChSrc2, /*!< Reserved */ - kSimTpmChSrc3 /*!< USB start of frame pulse */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_kl26z4_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateLpsci0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), -#endif - kSimClockGateCmp0 = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(4U, 22U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(4U, 23U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGateTsi0 = FSL_SIM_SCGC_BIT(5U, 5U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), -#if FSL_FEATURE_SOC_LCD_COUNT - kSimClockGateSlcd0 = FSL_SIM_SCGC_BIT(5U, 19U), -#endif - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateTpm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateTpm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateTpm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(6U, 31U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 8U) -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_kl26z4_t; -#else -} sim_clock_gate_name_t; -#endif - -/*@}*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTpmSrc(SIM_Type * base, - uint32_t instance, - clock_tpm_src_t setting) -{ - SIM_BWR_SOPT2_TPMSRC(base, setting); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_HAL_GetTpmSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_tpm_src_t)SIM_BRD_SOPT2_TPMSRC(base); -} - -/*! - * @brief Set the LPSCI clock source selection. - * - * This function sets the LPSCI clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetLpsciSrc(SIM_Type * base, - uint32_t instance, - clock_lpsci_src_t setting) -{ - SIM_BWR_SOPT2_UART0SRC(base, setting); -} - -/*! - * @brief Get the LPSCI clock source selection. - * - * This function gets the LPSCI clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_lpsci_src_t CLOCK_HAL_GetLpsciSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_lpsci_src_t)SIM_BRD_SOPT2_UART0SRC(base); -} -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -static inline void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - SIM_BWR_SOPT5_UART1RXSRC(base, select); -} - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -static inline sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); -} - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -static inline void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - SIM_BWR_SOPT5_UART1TXSRC(base, select); -} - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -static inline sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); -} - -/*! - * @brief Sets the LPSCIx receive data source select setting. - * - * This function selects the source for the LPSCIx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the LPSCIx receive data - */ -static inline void SIM_HAL_SetLpsciRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpsci_rxsrc_t select) -{ - SIM_BWR_SOPT5_UART0RXSRC(base, select); -} - -/*! - * @brief Gets the LPSCIx receive data source select setting. - * - * This function gets the LPSCIx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select LPSCIx receive data source select setting - */ -static inline sim_lpsci_rxsrc_t SIM_HAL_GetLpsciRxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_lpsci_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); -} - -/*! - * @brief Sets the LPSCIx transmit data source select setting. - * - * This function selects the source for the LPSCIx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the LPSCIx transmit data - */ -static inline void SIM_HAL_SetLpsciTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpsci_txsrc_t select) -{ - SIM_BWR_SOPT5_UART0TXSRC(base, select); -} - -/*! - * @brief Gets the LPSCIx transmit data source select setting. - * - * This function gets the LPSCIx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select LPSCIx transmit data source select setting - */ -static inline sim_lpsci_txsrc_t SIM_HAL_GetLpsciTxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_lpsci_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); -} - -#if FSL_FEATURE_SIM_OPT_HAS_ODE -/*! -* @brief Sets the UARTx Open Drain Enable setting. -* -* This function enables/disables the UARTx Open Drain. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @param enable Enable/disable UARTx Open Drain -* - True: Enable UARTx Open Drain -* - False: Disable UARTx Open Drain -*/ -void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable); - -/*! -* @brief Gets the UARTx Open Drain Enable setting. -* -* This function gets the UARTx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @return enabled True if UARTx Open Drain is enabled. -*/ -bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the LPSCIx Open Drain Enable setting. -* -* This function enables/disables the LPSCIx Open Drain. -* -* @param base Register base address of SIM. -* @param instance LPSCI instance. -* @param enable Enable/disable LPSCIx Open Drain -* - True: Enable LPSCIx Open Drain -* - False: Disable LPSCIx Open Drain -*/ -static inline void SIM_HAL_SetLpsciOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - SIM_BWR_SOPT5_UART0ODE(base, enable); -} - -/*! -* @brief Gets the LPSCIx Open Drain Enable setting. -* -* This function gets the LPSCIx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance LPSCI instance. -* @return enabled True if LPSCIx Open Drain is enabled. -*/ -static inline bool SIM_HAL_GetLpsciOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - return (bool)SIM_BRD_SOPT5_UART0ODE(base); -} -#endif - -#if FSL_FEATURE_SIM_OPT_HAS_TPM -/*! -* @brief Sets the Timer/PWM x external clock pin select setting. -* -* This function selects the source of the Timer/PWM x external clock pin select. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select Timer/PWM x external clock pin select -*/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select); - -/*! -* @brief Gets the Timer/PWM x external clock pin select setting. -* -* This function gets the Timer/PWM x external clock pin select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return Timer/PWM x external clock pin select setting -*/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the Timer/PWM x channel y input capture source select setting. -* -* This function selects the Timer/PWM x channel y input capture source. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @param select Timer/PWM x channel y input capture source -*/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select); - -/*! -* @brief Gets the Timer/PWM x channel y input capture source select setting. -* -* This function gets the Timer/PWM x channel y input capture source. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @return select Timer/PWM x channel y input capture source -*/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); -#endif - -/*! - * @brief Gets the Kinetis Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Family ID in the System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Family ID - */ -static inline uint32_t SIM_HAL_GetFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Sub-Family ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Sub-Family ID - */ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} - -/*! - * @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Series ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Series ID - */ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type * base) -{ - return SIM_BRD_SDID_SERIESID(base); -} - -/*! - * @brief Gets the Kinetis SramSize in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis SramSize in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis SramSize - */ -static inline uint32_t SIM_HAL_GetSramSize(SIM_Type * base) -{ - return SIM_BRD_SDID_SRAMSIZE(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the Kinetis Die ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Die ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Die ID - */ -static inline uint32_t SIM_HAL_GetDieId(SIM_Type * base) -{ - return SIM_BRD_SDID_DIEID(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_SIM_HAL_KL26Z4_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL27Z644/fsl_sim_hal_MKL27Z644.c b/KSDK_1.2.0/platform/hal/src/sim/MKL27Z644/fsl_sim_hal_MKL27Z644.c deleted file mode 100755 index 58799fb..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL27Z644/fsl_sim_hal_MKL27Z644.c +++ /dev/null @@ -1,384 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* -* Definitions -******************************************************************************/ - -/******************************************************************************* -* APIs -******************************************************************************/ - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_HAL_SetOutDiv -* Description : Set all clock out dividers setting at the same time -* This function will set the setting for all clock out dividers. -* -*END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = 0U; - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetLpuartSrc - * Description : Set the clock selection of LPUART. - * This function sets the clock selection of LPUART. - * - *END**************************************************************************/ -void CLOCK_HAL_SetLpuartSrc(SIM_Type * base, - uint32_t instance, - clock_lpuart_src_t setting) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0u == instance) - { - SIM_BWR_SOPT2_LPUART0SRC(base, setting); - } - else - { - SIM_BWR_SOPT2_LPUART1SRC(base, setting); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetLpuartSrc - * Description : Get the clock selection of LPUART. - * This function gets the clock selection of LPUART. - * - *END**************************************************************************/ -clock_lpuart_src_t CLOCK_HAL_GetLpuartSrc(SIM_Type * base, - uint32_t instance) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0u == instance) - { - return (clock_lpuart_src_t)SIM_BRD_SOPT2_LPUART0SRC(base); - } - else - { - return (clock_lpuart_src_t)SIM_BRD_SOPT2_LPUART1SRC(base); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmChSrcMode - * Description : Sets the Timer/PWM x channel y input capture source. - * - *END**************************************************************************/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select) -{ - assert(instance < TPM_INSTANCE_COUNT); - - if(instance == 1) - { - SIM_BWR_SOPT4_TPM1CH0SRC(base, select); - } - else if(instance == 2) - { - SIM_BWR_SOPT4_TPM2CH0SRC(base, select); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmChSrcMode - * Description : Sets the Timer/PWM x channel y input capture source. - * - *END**************************************************************************/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - assert(instance < TPM_INSTANCE_COUNT); - - sim_tpm_ch_src_t retValue = (sim_tpm_ch_src_t)0; - - if(instance == 1) - { - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM1CH0SRC(base); - } - else if(instance == 2) - { - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM2CH0SRC(base); - } - - return retValue; -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetLpuartRxSrcMode -* Description : Sets the LPUARTx receive data source select setting. -* -*END**************************************************************************/ -void SIM_HAL_SetLpuartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpuart_rxsrc_t select) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - SIM_BWR_SOPT5_LPUART0RXSRC(base, select); - } - else - { - SIM_BWR_SOPT5_LPUART1RXSRC(base, select); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_GetLpuartRxSrcMode -* Description : Gets the LPUARTx receive data source select setting. -* -*END**************************************************************************/ -sim_lpuart_rxsrc_t SIM_HAL_GetLpuartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - return (sim_lpuart_rxsrc_t)SIM_BRD_SOPT5_LPUART0RXSRC(base); - } - else - { - return (sim_lpuart_rxsrc_t)SIM_BRD_SOPT5_LPUART1RXSRC(base); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetLpuartTxSrcMode -* Description : Sets the LPUARTx transmit data source select setting. -* -*END**************************************************************************/ -void SIM_HAL_SetLpuartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpuart_txsrc_t select) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - SIM_BWR_SOPT5_LPUART0TXSRC(base, select); - } - else - { - SIM_BWR_SOPT5_LPUART1TXSRC(base, select); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetLpuartTxSrcMode -* Description : Sets the LPUARTx transmit data source select setting. -* -*END**************************************************************************/ -sim_lpuart_txsrc_t SIM_HAL_GetLpuartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - return (sim_lpuart_txsrc_t)SIM_BRD_SOPT5_LPUART0TXSRC(base); - } - else - { - return (sim_lpuart_txsrc_t)SIM_BRD_SOPT5_LPUART1TXSRC(base); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetLpuartOpenDrainCmd -* Description : This function enables/disables the LPUARTx Open Drain. -* -*END**************************************************************************/ -void SIM_HAL_SetLpuartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - SIM_BWR_SOPT5_LPUART0ODE(base, enable ? 1 : 0); - } - else - { - SIM_BWR_SOPT5_LPUART1ODE(base, enable ? 1 : 0); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_GetLpuartOpenDrainCmd -* Description : This function gets the LPUARTx Open Drain setting. -* -*END**************************************************************************/ -bool SIM_HAL_GetLpuartOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - return (bool)SIM_BRD_SOPT5_LPUART0ODE(base); - } - else - { - return (bool)SIM_BRD_SOPT5_LPUART1ODE(base); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetAdcTriggerModeOneStep -* Description : Set ADCx trigger setting. -* This function sets ADC alternate trigger, pre-trigger mode and trigger mode. -* -*END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - - if (altTrigEn) - { - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - } - -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetTpmExternalClkPinSelMode -* Description : Set Timer/PWM x external clock pin select setting -* This function will select the source of Timer/PWM x external clock pin select -* -*END**************************************************************************/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_TPM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_TPM1CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_GetTpmExternalClkPinSelMode -* Description : Get Timer/PWM x external clock pin select setting -* This function will get Timer/PWM x external clock pin select setting. -* -*END**************************************************************************/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance) -{ - sim_tpm_clk_sel_t retValue = (sim_tpm_clk_sel_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM0CLKSEL(base); - break; - case 1: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM1CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* -* EOF -******************************************************************************/ diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL27Z644/fsl_sim_hal_MKL27Z644.h b/KSDK_1.2.0/platform/hal/src/sim/MKL27Z644/fsl_sim_hal_MKL27Z644.h deleted file mode 100644 index 64c139b..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL27Z644/fsl_sim_hal_MKL27Z644.h +++ /dev/null @@ -1,1124 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#if !defined(__FSL_SIM_HAL_MKL27Z644_H__) -#define __FSL_SIM_HAL_MKL27Z644_H__ - -/*! - * @addtogroup sim_hal_kl27z644 - * @{ - */ -/*! @file*/ - -/******************************************************************************* -* Definitions -******************************************************************************/ -/*! @brief COP clock source selection.*/ -typedef enum _clock_cop_src { - kClockCopSrcLpoClk, /*!< LPO clock 1K HZ.*/ - kClockCopSrcMcgIrClk, /*!< MCG IRC Clock */ - kClockCopSrcOsc0erClk, /*!< OSCER Clock */ - kClockCopSrcBusClk /*!< BUS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -}clock_cop_src_kl27z644_t; -#else -}clock_cop_src_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U, /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_kl27z644_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM external reference clock output pin select (OSC32KOUT). */ -typedef enum _clock_osc32kout_sel -{ - kClockOsc32koutNone, /*!< ERCLK32K is not output. */ - kClockOsc32koutPte0, /*!< ERCLK32K output on PTE0 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_osc32kout_sel_kl27z644_t; -#else -} clock_osc32kout_sel_t; -#endif - -/*! @brief SIM LPUART clock source */ -typedef enum _clock_lpuart_src -{ - kClockLpuartSrcNone, /*!< disabled */ - kClockLpuartSrcIrc48M, /*!< IRC48M */ - kClockLpuartSrcOsc0erClk, /*!< OSCER clock */ - kClockLpuartSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lpuart_src_kl27z644_t; -#else -} clock_lpuart_src_t; -#endif - -/*! @brief SIM TPM clock source */ -typedef enum _clock_tpm_src -{ - kClockTpmSrcNone, /*!< disabled */ - kClockTpmSrcIrc48M, /*!< IRC48M/MCGPCLK */ - kClockTpmSrcOsc0erClk, /*!< OSCER clock */ - kClockTpmSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tpm_src_kl27z644_t; -#else -} clock_tpm_src_t; -#endif - -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcIrc48M, /*!< IRC48/MCGPCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_kl27z644_t; -#else -} clock_usbfs_src_t; -#endif - -/*! @brief FLEXIO clock source. */ -typedef enum _clock_flexio_src -{ - kClockFlexioSrcNone, /*!< Clock disabled. */ - kClockFlexioSrcIrc48M, /*!< MCGPCLK/IRC48M. */ - kClockFlexioSrcOsc0erClk, /*!< OSCERCLK. */ - kClockFlexioSrcMcgIrClk, /*!< MCGIRCLK. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_flexio_src_kl27z644_t; -#else -} clock_flexio_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG out clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk, /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_kl27z644_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCG out clock */ - kClockClkoutSelOsc0erClk = 6U, /*!< OSCER clock */ - kClockClkoutSelIrc48M = 7U /*!< IRC48M clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_kl27z644_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrcOsc0erClk, /*!< OSCER clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_kl27z644_t; -#else -} clock_rtcout_src_t; -#endif - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_kl27z644_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelComp0 = 1U, /*!< CMP0 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelTpm0 = 8U, /*!< TPM0 overflow */ - kSimAdcTrgSelTpm1 = 9U, /*!< TPM1 overflow */ - kSimAdcTrgSelTpm2 = 10U, /*!< TPM2 overflow */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U, /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_kl27z644_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief LPUART receive data source. */ -typedef enum _sim_lpuart_rxsrc -{ - kSimLpuartRxsrcPin, /*!< LPUARTx_RX Pin */ - kSimLpuartRxsrcCmp0, /*!< CMP0 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpuart_rxsrc_kl27z644_t; -#else -} sim_lpuart_rxsrc_t; -#endif - -/*! @brief LPUART transmit data source. */ -typedef enum _sim_lpuart_txsrc -{ - kSimLpuartTxsrcPin, /*!< UARTx_TX Pin */ - kSimLpuartTxsrcTpm1, /*!< UARTx_TX pin modulated with TPM1 channel 0 output */ - kSimLpuartTxsrcTpm2, /*!< UARTx_TX pin modulated with TPM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpuart_txsrc_kl27z644_t; -#else -} sim_lpuart_txsrc_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_kl27z644_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< Channel y input capture source uses 0. */ - kSimTpmChSrc1, /*!< Channel y input capture source uses 1. */ - kSimTpmChSrc2, /*!< Channel y input capture source uses 2. */ - kSimTpmChSrc3, /*!< Channel y input capture source uses 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_kl27z644_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), - kSimClockGateCmp0 = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(4U, 22U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(4U, 23U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - kSimClockGateLpuart0 = FSL_SIM_SCGC_BIT(5U, 20U), - kSimClockGateLpuart1 = FSL_SIM_SCGC_BIT(5U, 21U), - kSimClockGateFlexio0 = FSL_SIM_SCGC_BIT(5U, 31U), - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateTpm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateTpm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateTpm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 8U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_kl27z644_t; -#else -} sim_clock_gate_name_t; -#endif - -/*@}*/ - -/******************************************************************************* -* API -******************************************************************************/ -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! -* @brief Disable the clock for specific module. -* -* This function disables the clock for specific module. -* -* @param base Base address for current SIM instance. -* @param name Name of the module to disable. -*/ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! -* @brief Get the the clock gate state for specific module. -* -* This function will get the clock gate state for specific module. -* -* @param base Base address for current SIM instance. -* @param name Name of the module to get. -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! -* @brief Set the clock selection of LPUART. -* -* This function sets the clock selection of LPUART. -* -* @param base Base address for current SIM instance. -* @param instance LPUART instance. -* @param setting The value to set. -*/ -void CLOCK_HAL_SetLpuartSrc(SIM_Type * base, - uint32_t instance, - clock_lpuart_src_t setting); - -/*! -* @brief Get the clock selection of LPUART. -* -* This function gets the clock selection of LPUART. -* -* @param base Base address for current SIM instance. -* @param instance LPUART instance. -* @return Current selection. -*/ -clock_lpuart_src_t CLOCK_HAL_GetLpuartSrc(SIM_Type * base, - uint32_t instance); - -/*! -* @brief Set the clock selection of TPM. -* -* This function sets the clock selection of TPM. -* -* @param base Base address for current SIM instance. -* @param instance IP instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetTpmSrc(SIM_Type * base, - uint32_t instance, - clock_tpm_src_t setting) -{ - SIM_BWR_SOPT2_TPMSRC(base, setting); -} - -/*! -* @brief Get the clock selection of TPM. -* -* This function gets the clock selection of TPM. -* -* @param base Base address for current SIM instance. -* @param instance IP instance. -* @return Current selection. -*/ -static inline clock_tpm_src_t CLOCK_HAL_GetTpmSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_tpm_src_t)SIM_BRD_SOPT2_TPMSRC(base); -} - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} - -/*! - * @brief Select the clock source for FLEXIO. - * - * This function selects the clock source for FLEXIO. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetFlexioSrc(SIM_Type * base, - uint32_t instance, - clock_flexio_src_t setting) -{ - SIM_BWR_SOPT2_FLEXIOSRC(base, setting); -} - -/*! - * @brief Get the clock source of FLEXIO. - * - * This function gets the clock source of FLEXIO. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_flexio_src_t CLOCK_HAL_GetFlexioSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_flexio_src_t)SIM_BRD_SOPT2_FLEXIOSRC(base); -} - -/*! -* @brief Set the clock ERCLK32K output on selected pin. -* -* This function sets ERCLK32K output on selected pin. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetOsc32kOutSel(SIM_Type * base, - clock_osc32kout_sel_t setting) -{ - SIM_BWR_SOPT1_OSC32KOUT(base, setting); -} - -/*! -* @brief Get output status of ERCLK32K. -* -* This function gets the output status of ERCLK32K. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_osc32kout_sel_t CLOCK_HAL_GetOsc32kOutSel(SIM_Type * base) -{ - return (clock_osc32kout_sel_t)SIM_BRD_SOPT1_OSC32KOUT(base); -} - - -/*! -* @brief Set the clock selection of ERCLK32K. -* -* This function sets the clock selection of ERCLK32K. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! -* @brief Get the clock selection of ERCLK32K. -* -* This function gets the clock selection of ERCLK32K. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! -* @brief Set CLKOUTSEL selection. -* -* This function sets the selection of the clock to output on the CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! -* @brief Get CLKOUTSEL selection. -* -* This function gets the selection of the clock to output on the CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! -* @brief Set RTCCLKOUTSEL selection. -* -* This function sets the selection of the clock to output on the RTC_CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! -* @brief Get RTCCLKOUTSEL selection. -* -* This function gets the selection of the clock to output on the RTC_CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - - -/*! -* @brief Set the clock selection of COP. -* -* This function sets the clock selection of COP. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetCopSrc(SIM_Type * base, - clock_cop_src_t setting) -{ - SIM_BWR_COPC_COPCLKSEL(base, setting); -} - -/*! -* @brief Get the clock selection of COP. -* -* This function gets the clock selection of COP. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_cop_src_t CLOCK_HAL_GetCopSrc(SIM_Type * base) -{ - return (clock_cop_src_t)SIM_BRD_COPC_COPCLKSEL(base); -} - - -/*! -* @brief Set OUTDIV1. -* -* This function sets divide value OUTDIV1. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! -* @brief Get OUTDIV1. -* -* This function gets divide value OUTDIV1. -* -* @param base Base address for current SIM instance. -* @return Current divide value. -*/ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! -* @brief Set OUTDIV4. -* -* This function sets divide value OUTDIV4. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! -* @brief Get OUTDIV4. -* -* This function gets divide value OUTDIV4. -* -* @param base Base address for current SIM instance. -* @return Current divide value. -*/ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -/*! -* @brief Sets the ADCx alternate trigger enable setting. -* -* This function enables/disables the alternative conversion triggers for ADCx. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param enable Enable alternative conversion triggers for ADCx -* - true: Select alternative conversion trigger. -* - false: Select PDB trigger. -*/ -static inline void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - -} -/*! -* @brief Gets the ADCx alternate trigger enable setting. -* -* This function gets the ADCx alternate trigger enable setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return enabled True if ADCx alternate trigger is enabled -*/ - -static inline bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - - return retValue; -} - - -/*! -* @brief Sets the ADCx pre-trigger select setting. -* -* This function selects the ADCx pre-trigger source when the alternative -* triggers are enabled through ADCxALTTRGEN. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select pre-trigger select setting for ADCx -*/ -static inline void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - -} -/*! -* @brief Gets the ADCx pre-trigger select setting. -* -* This function gets the ADCx pre-trigger select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return select ADCx pre-trigger select setting -*/ -static inline sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - - return retValue; -} - -/*! -* @brief Sets the ADCx trigger select setting. -* -* This function selects the ADCx trigger source when alternative triggers -* are enabled through ADCxALTTRGEN. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select trigger select setting for ADCx -*/ -static inline void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - -} - -/*! -* @brief Gets the ADCx trigger select setting. -* -* This function gets the ADCx trigger select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return ADCx trigger select setting -*/ -static inline sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - - return retValue; -} - -/*! -* @brief Sets the ADCx trigger select setting in one function. -* -* This function sets ADC alternate trigger, pre-trigger mode and trigger mode. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param altTrigEn Alternative trigger enable or not. -* @param preTrigSel Pre-trigger mode. -* @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! -* @brief Sets the LPUARTx receive data source select setting. -* -* This function selects the source for the LPUARTx receive data. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @param select the source for the LPUARTx receive data -*/ -void SIM_HAL_SetLpuartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpuart_rxsrc_t select); - -/*! -* @brief Gets the LPUARTx receive data source select setting. -* -* This function gets the LPUARTx receive data source select setting. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* -* @return select UARTx receive data source select setting -*/ -sim_lpuart_rxsrc_t SIM_HAL_GetLpuartRxSrcMode(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the LPUARTx transmit data source select setting. -* -* This function selects the source for the LPUARTx transmit data. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @param select the source for the UARTx transmit data. -*/ -void SIM_HAL_SetLpuartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpuart_txsrc_t select); - -/*! -* @brief Gets the LPUARTx transmit data source select setting. -* -* This function gets the LPUARTx transmit data source select setting. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @return select UARTx transmit data source select setting. -*/ -sim_lpuart_txsrc_t SIM_HAL_GetLpuartTxSrcMode(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the LPUARTx Open Drain Enable setting. -* -* This function enables/disables the LPUARTx Open Drain. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @param enable Enable/disable LPUARTx Open Drain -* - True: Enable LPUARTx Open Drain -* - False: Disable LPUARTx Open Drain -*/ -void SIM_HAL_SetLpuartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable); - -/*! -* @brief Gets the LPUARTx Open Drain Enable setting. -* -* This function gets the LPUARTx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @return enabled True if LPUARTx Open Drain is enabled. -*/ -bool SIM_HAL_GetLpuartOpenDrainCmd(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the UARTx Open Drain Enable setting. -* -* This function enables/disables the UARTx Open Drain. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @param enable Enable/disable UARTx Open Drain -* - True: Enable UARTx Open Drain -* - False: Disable UARTx Open Drain -*/ -static inline void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - // Only support UART2 - assert (2 == instance); - SIM_BWR_SOPT5_UART2ODE(base, enable ? 1 : 0); -} - -/*! -* @brief Gets the UARTx Open Drain Enable setting. -* -* This function gets the UARTx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @return enabled True if UARTx Open Drain is enabled. -*/ -static inline bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, - uint32_t instance) -{ - // Only support UART2 - assert (2 == instance); - return (bool)SIM_BRD_SOPT5_UART2ODE(base); -} - -/*! -* @brief Sets the Timer/PWM x channel y input capture source select setting. -* -* This function selects the Timer/PWM x channel y input capture source. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @param select Timer/PWM x channel y input capture source -*/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select); - -/*! -* @brief Gets the Timer/PWM x channel y input capture source select setting. -* -* This function gets the Timer/PWM x channel y input capture source select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel Tpm channel y -* @return select Timer/PWM x channel y input capture source select setting -*/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! -* @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Sub-Family ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Sub-Family ID -*/ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} - -/*! -* @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Series ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Series ID -*/ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type * base) -{ - return SIM_BRD_SDID_SERIESID(base); -} - -/*! -* @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Fam ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Fam ID -*/ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! -* @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Pincount ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Pincount ID -*/ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! -* @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Revision ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Revision ID -*/ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! -* @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function gets the program flash size in the Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @return size Program flash Size -*/ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! -* @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function sets the Flash Doze in the Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @param setting Flash Doze setting -*/ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! -* @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function gets the Flash Doze in the Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @return setting Flash Doze setting -*/ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! -* @brief Sets the Flash disable setting. -* -* This function sets the Flash disable setting in the -* Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @param disable Flash disable setting -*/ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! -* @brief Gets the Flash disable setting. -* -* This function gets the Flash disable setting in the -* Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @return setting Flash disable setting -*/ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! -* @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function gets the Flash maximum block 0 in Flash Configuration Register 2. -* -* @param base Base address for current SIM instance. -* @return address Flash maximum block 0 address -*/ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! -* @brief Sets the Timer/PWM x external clock pin select setting. -* -* This function selects the source of the Timer/PWM x external clock pin select. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select Timer/PWM x external clock pin select -* - 0: Timer/PWM x external clock driven by the TPM_CLKIN0 pin. -* - 1: Timer/PWM x external clock driven by the TPM_CLKIN1 pin. -*/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select); - -/*! -* @brief Gets the Timer/PWM x external clock pin select setting. -* -* This function gets the Timer/PWM x external clock pin select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return select Timer/PWM x external clock pin select setting -*/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance); - - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_SIM_HAL_MKL27Z644_H__*/ -/******************************************************************************* -* EOF -******************************************************************************/ diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL33Z4/fsl_sim_hal_MKL33Z4.c b/KSDK_1.2.0/platform/hal/src/sim/MKL33Z4/fsl_sim_hal_MKL33Z4.c deleted file mode 100755 index 58799fb..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL33Z4/fsl_sim_hal_MKL33Z4.c +++ /dev/null @@ -1,384 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* -* Definitions -******************************************************************************/ - -/******************************************************************************* -* APIs -******************************************************************************/ - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_HAL_SetOutDiv -* Description : Set all clock out dividers setting at the same time -* This function will set the setting for all clock out dividers. -* -*END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = 0U; - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetLpuartSrc - * Description : Set the clock selection of LPUART. - * This function sets the clock selection of LPUART. - * - *END**************************************************************************/ -void CLOCK_HAL_SetLpuartSrc(SIM_Type * base, - uint32_t instance, - clock_lpuart_src_t setting) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0u == instance) - { - SIM_BWR_SOPT2_LPUART0SRC(base, setting); - } - else - { - SIM_BWR_SOPT2_LPUART1SRC(base, setting); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetLpuartSrc - * Description : Get the clock selection of LPUART. - * This function gets the clock selection of LPUART. - * - *END**************************************************************************/ -clock_lpuart_src_t CLOCK_HAL_GetLpuartSrc(SIM_Type * base, - uint32_t instance) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0u == instance) - { - return (clock_lpuart_src_t)SIM_BRD_SOPT2_LPUART0SRC(base); - } - else - { - return (clock_lpuart_src_t)SIM_BRD_SOPT2_LPUART1SRC(base); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmChSrcMode - * Description : Sets the Timer/PWM x channel y input capture source. - * - *END**************************************************************************/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select) -{ - assert(instance < TPM_INSTANCE_COUNT); - - if(instance == 1) - { - SIM_BWR_SOPT4_TPM1CH0SRC(base, select); - } - else if(instance == 2) - { - SIM_BWR_SOPT4_TPM2CH0SRC(base, select); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmChSrcMode - * Description : Sets the Timer/PWM x channel y input capture source. - * - *END**************************************************************************/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - assert(instance < TPM_INSTANCE_COUNT); - - sim_tpm_ch_src_t retValue = (sim_tpm_ch_src_t)0; - - if(instance == 1) - { - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM1CH0SRC(base); - } - else if(instance == 2) - { - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM2CH0SRC(base); - } - - return retValue; -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetLpuartRxSrcMode -* Description : Sets the LPUARTx receive data source select setting. -* -*END**************************************************************************/ -void SIM_HAL_SetLpuartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpuart_rxsrc_t select) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - SIM_BWR_SOPT5_LPUART0RXSRC(base, select); - } - else - { - SIM_BWR_SOPT5_LPUART1RXSRC(base, select); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_GetLpuartRxSrcMode -* Description : Gets the LPUARTx receive data source select setting. -* -*END**************************************************************************/ -sim_lpuart_rxsrc_t SIM_HAL_GetLpuartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - return (sim_lpuart_rxsrc_t)SIM_BRD_SOPT5_LPUART0RXSRC(base); - } - else - { - return (sim_lpuart_rxsrc_t)SIM_BRD_SOPT5_LPUART1RXSRC(base); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetLpuartTxSrcMode -* Description : Sets the LPUARTx transmit data source select setting. -* -*END**************************************************************************/ -void SIM_HAL_SetLpuartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpuart_txsrc_t select) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - SIM_BWR_SOPT5_LPUART0TXSRC(base, select); - } - else - { - SIM_BWR_SOPT5_LPUART1TXSRC(base, select); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetLpuartTxSrcMode -* Description : Sets the LPUARTx transmit data source select setting. -* -*END**************************************************************************/ -sim_lpuart_txsrc_t SIM_HAL_GetLpuartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - return (sim_lpuart_txsrc_t)SIM_BRD_SOPT5_LPUART0TXSRC(base); - } - else - { - return (sim_lpuart_txsrc_t)SIM_BRD_SOPT5_LPUART1TXSRC(base); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetLpuartOpenDrainCmd -* Description : This function enables/disables the LPUARTx Open Drain. -* -*END**************************************************************************/ -void SIM_HAL_SetLpuartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - SIM_BWR_SOPT5_LPUART0ODE(base, enable ? 1 : 0); - } - else - { - SIM_BWR_SOPT5_LPUART1ODE(base, enable ? 1 : 0); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_GetLpuartOpenDrainCmd -* Description : This function gets the LPUARTx Open Drain setting. -* -*END**************************************************************************/ -bool SIM_HAL_GetLpuartOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - return (bool)SIM_BRD_SOPT5_LPUART0ODE(base); - } - else - { - return (bool)SIM_BRD_SOPT5_LPUART1ODE(base); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetAdcTriggerModeOneStep -* Description : Set ADCx trigger setting. -* This function sets ADC alternate trigger, pre-trigger mode and trigger mode. -* -*END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - - if (altTrigEn) - { - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - } - -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetTpmExternalClkPinSelMode -* Description : Set Timer/PWM x external clock pin select setting -* This function will select the source of Timer/PWM x external clock pin select -* -*END**************************************************************************/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_TPM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_TPM1CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_GetTpmExternalClkPinSelMode -* Description : Get Timer/PWM x external clock pin select setting -* This function will get Timer/PWM x external clock pin select setting. -* -*END**************************************************************************/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance) -{ - sim_tpm_clk_sel_t retValue = (sim_tpm_clk_sel_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM0CLKSEL(base); - break; - case 1: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM1CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* -* EOF -******************************************************************************/ diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL33Z4/fsl_sim_hal_MKL33Z4.h b/KSDK_1.2.0/platform/hal/src/sim/MKL33Z4/fsl_sim_hal_MKL33Z4.h deleted file mode 100644 index 6e94551..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL33Z4/fsl_sim_hal_MKL33Z4.h +++ /dev/null @@ -1,1371 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#if !defined(__FSL_SIM_HAL_MKL33Z4_H__) -#define __FSL_SIM_HAL_MKL33Z4_H__ - - -/*! - * @addtogroup sim_hal_kl33z4 - * @{ - */ -/*! @file*/ - -/******************************************************************************* -* Definitions -******************************************************************************/ -/*! @brief COP clock source selection.*/ -typedef enum _clock_cop_src { - kClockCopSrcLpoClk, /*!< LPO clock 1K HZ.*/ - kClockCopSrcMcgIrClk, /*!< MCG IRC Clock */ - kClockCopSrcOsc0erClk, /*!< OSCER Clock */ - kClockCopSrcBusClk /*!< BUS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -}clock_cop_src_kl33z4_t; -#else -}clock_cop_src_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U, /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_kl33z4_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM external reference clock output pin select (OSC32KOUT). */ -typedef enum _clock_osc32kout_sel -{ - kClockOsc32koutNone = 0U, /*!< ERCLK32K is not output. */ - kClockOsc32koutPte0 = 1U, /*!< ERCLK32K is output on PTE0. */ - kClockOsc32koutPte26 = 2U, /*!< ERCLK32K is output on PTE26. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_osc32kout_sel_kl33z4_t; -#else -} clock_osc32kout_sel_t; -#endif - -/*! @brief SIM LPUART clock source */ -typedef enum _clock_lpuart_src -{ - kClockLpuartSrcNone, /*!< disabled */ - kClockLpuartSrcIrc48M, /*!< IRC48M */ - kClockLpuartSrcOsc0erClk, /*!< OSCER clock */ - kClockLpuartSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lpuart_src_kl33z4_t; -#else -} clock_lpuart_src_t; -#endif - -/*! @brief SIM TPM clock source */ -typedef enum _clock_tpm_src -{ - kClockTpmSrcNone, /*!< disabled */ - kClockTpmSrcIrc48M, /*!< IRC48M/MCGPCLK */ - kClockTpmSrcOsc0erClk, /*!< OSCER clock */ - kClockTpmSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tpm_src_kl33z4_t; -#else -} clock_tpm_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcIrc48M, /*!< IRC48/MCGPCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_kl33z4_t; -#else -} clock_usbfs_src_t; -#endif -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! @brief FLEXIO clock source. */ -typedef enum _clock_flexio_src -{ - kClockFlexioSrcNone, /*!< Clock disabled. */ - kClockFlexioSrcIrc48M, /*!< MCGPCLK/IRC48M. */ - kClockFlexioSrcOsc0erClk, /*!< OSCERCLK. */ - kClockFlexioSrcMcgIrClk, /*!< MCGIRCLK. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_flexio_src_kl33z4_t; -#else -} clock_flexio_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG out clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk, /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_kl33z4_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCG out clock */ - kClockClkoutSelOsc0erClk = 6U, /*!< OSCER clock */ - kClockClkoutSelIrc48M = 7U /*!< IRC48M clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_kl33z4_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrcOsc0erClk, /*!< OSCER clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_kl33z4_t; -#else -} clock_rtcout_src_t; -#endif - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_kl33z4_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelComp0 = 1U, /*!< CMP0 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelTpm0 = 8U, /*!< TPM0 overflow */ - kSimAdcTrgSelTpm1 = 9U, /*!< TPM1 overflow */ - kSimAdcTrgSelTpm2 = 10U, /*!< TPM2 overflow */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U, /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_kl33z4_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief LPUART receive data source. */ -typedef enum _sim_lpuart_rxsrc -{ - kSimLpuartRxsrcPin, /*!< LPUARTx_RX Pin */ - kSimLpuartRxsrcCmp0, /*!< CMP0 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpuart_rxsrc_kl33z4_t; -#else -} sim_lpuart_rxsrc_t; -#endif - -/*! @brief LPUART transmit data source. */ -typedef enum _sim_lpuart_txsrc -{ - kSimLpuartTxsrcPin, /*!< UARTx_TX Pin */ - kSimLpuartTxsrcTpm1, /*!< UARTx_TX pin modulated with TPM1 channel 0 output */ - kSimLpuartTxsrcTpm2, /*!< UARTx_TX pin modulated with TPM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpuart_txsrc_kl33z4_t; -#else -} sim_lpuart_txsrc_t; -#endif - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcMcgIrClk = 2U, /*!< MCGIRCLK */ - kClockSaiSrcIrc48M = 3U, /*!< MCGPCLK/IRC48M. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_kl33z4_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_kl33z4_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< Channel y input capture source uses 0. */ - kSimTpmChSrc1, /*!< Channel y input capture source uses 1. */ - kSimTpmChSrc2, /*!< Channel y input capture source uses 2. */ - kSimTpmChSrc3, /*!< Channel y input capture source uses 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_kl33z4_t; -#else -} sim_tpm_ch_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_kl33z4_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_kl33z4_t; -#else -} sim_usbvstby_mode_t; -#endif -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), -#endif - kSimClockGateCmp0 = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(4U, 22U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(4U, 23U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), -#if FSL_FEATURE_SOC_LCD_COUNT - kSimClockGateSlcd0 = FSL_SIM_SCGC_BIT(5U, 19U), -#endif - kSimClockGateLpuart0 = FSL_SIM_SCGC_BIT(5U, 20U), - kSimClockGateLpuart1 = FSL_SIM_SCGC_BIT(5U, 21U), - kSimClockGateFlexio0 = FSL_SIM_SCGC_BIT(5U, 31U), - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateTpm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateTpm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateTpm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(6U, 31U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 8U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_kl33z4_t; -#else -} sim_clock_gate_name_t; -#endif - -/*@}*/ - -/******************************************************************************* -* API -******************************************************************************/ -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! -* @brief Disable the clock for specific module. -* -* This function disables the clock for specific module. -* -* @param base Base address for current SIM instance. -* @param name Name of the module to disable. -*/ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! -* @brief Get the the clock gate state for specific module. -* -* This function will get the clock gate state for specific module. -* -* @param base Base address for current SIM instance. -* @param name Name of the module to get. -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! -* @brief Set the clock selection of LPUART. -* -* This function sets the clock selection of LPUART. -* -* @param base Base address for current SIM instance. -* @param instance LPUART instance. -* @param setting The value to set. -*/ -void CLOCK_HAL_SetLpuartSrc(SIM_Type * base, - uint32_t instance, - clock_lpuart_src_t setting); - -/*! -* @brief Get the clock selection of LPUART. -* -* This function gets the clock selection of LPUART. -* -* @param base Base address for current SIM instance. -* @param instance LPUART instance. -* @return Current selection. -*/ -clock_lpuart_src_t CLOCK_HAL_GetLpuartSrc(SIM_Type * base, - uint32_t instance); - -/*! -* @brief Set the clock selection of TPM. -* -* This function sets the clock selection of TPM. -* -* @param base Base address for current SIM instance. -* @param instance IP instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetTpmSrc(SIM_Type * base, - uint32_t instance, - clock_tpm_src_t setting) -{ - SIM_BWR_SOPT2_TPMSRC(base, setting); -} - -/*! -* @brief Get the clock selection of TPM. -* -* This function gets the clock selection of TPM. -* -* @param base Base address for current SIM instance. -* @param instance IP instance. -* @return Current selection. -*/ -static inline clock_tpm_src_t CLOCK_HAL_GetTpmSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_tpm_src_t)SIM_BRD_SOPT2_TPMSRC(base); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Select the clock source for FLEXIO. - * - * This function selects the clock source for FLEXIO. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetFlexioSrc(SIM_Type * base, - uint32_t instance, - clock_flexio_src_t setting) -{ - SIM_BWR_SOPT2_FLEXIOSRC(base, setting); -} - -/*! - * @brief Get the clock source of FLEXIO. - * - * This function gets the clock source of FLEXIO. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_flexio_src_t CLOCK_HAL_GetFlexioSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_flexio_src_t)SIM_BRD_SOPT2_FLEXIOSRC(base); -} - -/*! -* @brief Set the clock ERCLK32K output on selected pin. -* -* This function sets ERCLK32K output on selected pin. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetOsc32kOutSel(SIM_Type * base, - clock_osc32kout_sel_t setting) -{ - SIM_BWR_SOPT1_OSC32KOUT(base, setting); -} - -/*! -* @brief Get output status of ERCLK32K. -* -* This function gets the output status of ERCLK32K. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_osc32kout_sel_t CLOCK_HAL_GetOsc32kOutSel(SIM_Type * base) -{ - return (clock_osc32kout_sel_t)SIM_BRD_SOPT1_OSC32KOUT(base); -} - - -/*! -* @brief Set the clock selection of ERCLK32K. -* -* This function sets the clock selection of ERCLK32K. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! -* @brief Get the clock selection of ERCLK32K. -* -* This function gets the clock selection of ERCLK32K. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! -* @brief Set CLKOUTSEL selection. -* -* This function sets the selection of the clock to output on the CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! -* @brief Get CLKOUTSEL selection. -* -* This function gets the selection of the clock to output on the CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! -* @brief Set RTCCLKOUTSEL selection. -* -* This function sets the selection of the clock to output on the RTC_CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! -* @brief Get RTCCLKOUTSEL selection. -* -* This function gets the selection of the clock to output on the RTC_CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - - -/*! -* @brief Set the clock selection of COP. -* -* This function sets the clock selection of COP. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetCopSrc(SIM_Type * base, - clock_cop_src_t setting) -{ - SIM_BWR_COPC_COPCLKSEL(base, setting); -} - -/*! -* @brief Get the clock selection of COP. -* -* This function gets the clock selection of COP. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_cop_src_t CLOCK_HAL_GetCopSrc(SIM_Type * base) -{ - return (clock_cop_src_t)SIM_BRD_COPC_COPCLKSEL(base); -} - - -/*! -* @brief Set OUTDIV1. -* -* This function sets divide value OUTDIV1. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! -* @brief Get OUTDIV1. -* -* This function gets divide value OUTDIV1. -* -* @param base Base address for current SIM instance. -* @return Current divide value. -*/ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! -* @brief Set OUTDIV4. -* -* This function sets divide value OUTDIV4. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! -* @brief Get OUTDIV4. -* -* This function gets divide value OUTDIV4. -* -* @param base Base address for current SIM instance. -* @return Current divide value. -*/ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif //FSL_FEATURE_SOC_USB_COUNT - -/*! -* @brief Sets the ADCx alternate trigger enable setting. -* -* This function enables/disables the alternative conversion triggers for ADCx. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param enable Enable alternative conversion triggers for ADCx -* - true: Select alternative conversion trigger. -* - false: Select PDB trigger. -*/ -static inline void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - -} - -/*! -* @brief Gets the ADCx alternate trigger enable setting. -* -* This function gets the ADCx alternate trigger enable setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return enabled True if ADCx alternate trigger is enabled -*/ - -static inline bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - - return retValue; -} - -/*! -* @brief Sets the ADCx pre-trigger select setting. -* -* This function selects the ADCx pre-trigger source when the alternative -* triggers are enabled through ADCxALTTRGEN. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select pre-trigger select setting for ADCx -*/ -static inline void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - -} -/*! -* @brief Gets the ADCx pre-trigger select setting. -* -* This function gets the ADCx pre-trigger select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return select ADCx pre-trigger select setting -*/ -static inline sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - - return retValue; -} - -/*! -* @brief Sets the ADCx trigger select setting. -* -* This function selects the ADCx trigger source when alternative triggers -* are enabled through ADCxALTTRGEN. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select trigger select setting for ADCx -*/ -static inline void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - -} - -/*! -* @brief Gets the ADCx trigger select setting. -* -* This function gets the ADCx trigger select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return ADCx trigger select setting -*/ -static inline sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - - return retValue; -} - -/*! -* @brief Sets the ADCx trigger select setting in one function. -* -* This function sets ADC alternate trigger, pre-trigger mode and trigger mode. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param altTrigEn Alternative trigger enable or not. -* @param preTrigSel Pre-trigger mode. -* @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! -* @brief Sets the LPUARTx receive data source select setting. -* -* This function selects the source for the LPUARTx receive data. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @param select the source for the LPUARTx receive data -*/ -void SIM_HAL_SetLpuartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpuart_rxsrc_t select); - -/*! -* @brief Gets the LPUARTx receive data source select setting. -* -* This function gets the LPUARTx receive data source select setting. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* -* @return select UARTx receive data source select setting -*/ -sim_lpuart_rxsrc_t SIM_HAL_GetLpuartRxSrcMode(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the LPUARTx transmit data source select setting. -* -* This function selects the source for the LPUARTx transmit data. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @param select the source for the UARTx transmit data. -*/ -void SIM_HAL_SetLpuartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpuart_txsrc_t select); - -/*! -* @brief Gets the LPUARTx transmit data source select setting. -* -* This function gets the LPUARTx transmit data source select setting. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @return select UARTx transmit data source select setting. -*/ -sim_lpuart_txsrc_t SIM_HAL_GetLpuartTxSrcMode(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the LPUARTx Open Drain Enable setting. -* -* This function enables/disables the LPUARTx Open Drain. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @param enable Enable/disable LPUARTx Open Drain -* - True: Enable LPUARTx Open Drain -* - False: Disable LPUARTx Open Drain -*/ -void SIM_HAL_SetLpuartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable); - -/*! -* @brief Gets the LPUARTx Open Drain Enable setting. -* -* This function gets the LPUARTx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @return enabled True if LPUARTx Open Drain is enabled. -*/ -bool SIM_HAL_GetLpuartOpenDrainCmd(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the UARTx Open Drain Enable setting. -* -* This function enables/disables the UARTx Open Drain. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @param enable Enable/disable UARTx Open Drain -* - True: Enable UARTx Open Drain -* - False: Disable UARTx Open Drain -*/ -static inline void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - // Only support UART2 - assert (2 == instance); - SIM_BWR_SOPT5_UART2ODE(base, enable ? 1 : 0); -} - -/*! -* @brief Gets the UARTx Open Drain Enable setting. -* -* This function gets the UARTx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @return enabled True if UARTx Open Drain is enabled. -*/ -static inline bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, - uint32_t instance) -{ - // Only support UART2 - assert (2 == instance); - return (bool)SIM_BRD_SOPT5_UART2ODE(base); -} - -/*! -* @brief Sets the Timer/PWM x channel y input capture source select setting. -* -* This function selects the Timer/PWM x channel y input capture source. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @param select Timer/PWM x channel y input capture source -*/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select); - -/*! -* @brief Gets the Timer/PWM x channel y input capture source select setting. -* -* This function gets the Timer/PWM x channel y input capture source select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel Tpm channel y -* @return select Timer/PWM x channel y input capture source select setting -*/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! -* @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Sub-Family ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Sub-Family ID -*/ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} - -/*! -* @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Series ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Series ID -*/ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type * base) -{ - return SIM_BRD_SDID_SERIESID(base); -} - -/*! -* @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Fam ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Fam ID -*/ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! -* @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Pincount ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Pincount ID -*/ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! -* @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Revision ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Revision ID -*/ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! -* @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function gets the program flash size in the Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @return size Program flash Size -*/ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! -* @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function sets the Flash Doze in the Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @param setting Flash Doze setting -*/ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! -* @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function gets the Flash Doze in the Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @return setting Flash Doze setting -*/ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! -* @brief Sets the Flash disable setting. -* -* This function sets the Flash disable setting in the -* Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @param disable Flash disable setting -*/ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! -* @brief Gets the Flash disable setting. -* -* This function gets the Flash disable setting in the -* Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @return setting Flash disable setting -*/ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! -* @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function gets the Flash maximum block 0 in Flash Configuration Register 2. -* -* @param base Base address for current SIM instance. -* @return address Flash maximum block 0 address -*/ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -/*! -* @brief Sets the Timer/PWM x external clock pin select setting. -* -* This function selects the source of the Timer/PWM x external clock pin select. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select Timer/PWM x external clock pin select -* - 0: Timer/PWM x external clock driven by the TPM_CLKIN0 pin. -* - 1: Timer/PWM x external clock driven by the TPM_CLKIN1 pin. -*/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select); - -/*! -* @brief Gets the Timer/PWM x external clock pin select setting. -* -* This function gets the Timer/PWM x external clock pin select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return select Timer/PWM x external clock pin select setting -*/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance); - - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_SIM_HAL_MKL33Z4_H__*/ -/******************************************************************************* -* EOF -******************************************************************************/ diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL34Z4/fsl_sim_hal_MKL34Z4.c b/KSDK_1.2.0/platform/hal/src/sim/MKL34Z4/fsl_sim_hal_MKL34Z4.c deleted file mode 100755 index 11e5e13..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL34Z4/fsl_sim_hal_MKL34Z4.c +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = 0U; - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable settingg - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, uint32_t instance, sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue =(sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - - if (altTrigEn) - { - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartOpenDrainCmd - * Description : Set UARTx Open Drain Enable setting - * This function will enable/disable the UARTx Open Drain. - * - *END**************************************************************************/ -void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 1: - SIM_BWR_SOPT5_UART1ODE(base, enable ? 1 : 0); - break; - case 2: - SIM_BWR_SOPT5_UART2ODE(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartOpenDrainCmd - * Description : Get UARTx Open Drain Enable setting - * This function will get UARTx Open Drain Enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 1: - retValue = SIM_BRD_SOPT5_UART1ODE(base); - break; - case 2: - retValue = SIM_BRD_SOPT5_UART2ODE(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmExternalClkPinSelMode - * Description : Set Timer/PWM x external clock pin select setting - * This function will select the source of Timer/PWM x external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_TPM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_TPM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_TPM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetTpmExternalClkPinSelMode - * Description : Get Timer/PWM x external clock pin select setting - * This function will get Timer/PWM x external clock pin select setting. - * - *END**************************************************************************/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance) -{ - sim_tpm_clk_sel_t retValue = (sim_tpm_clk_sel_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM0CLKSEL(base); - break; - case 1: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM1CLKSEL(base); - break; - case 2: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmChSrcMode - * Description : Timer/PWM x channel y input capture source select setting - * This function will select Timer/PWM x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - SIM_BWR_SOPT4_TPM1CH0SRC(base, select); - break; - case 2: - SIM_BWR_SOPT4_TPM2CH0SRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetTpmChSrcMode - * Description : Get Timer/PWM x channel y input capture source select setting - * This function will get Timer/PWM x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_tpm_ch_src_t retValue = (sim_tpm_ch_src_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM1CH0SRC(base); - break; - case 2: - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM2CH0SRC(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL34Z4/fsl_sim_hal_MKL34Z4.h b/KSDK_1.2.0/platform/hal/src/sim/MKL34Z4/fsl_sim_hal_MKL34Z4.h deleted file mode 100644 index 4139b13..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL34Z4/fsl_sim_hal_MKL34Z4.h +++ /dev/null @@ -1,1397 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_KL34Z4_H__) -#define __FSL_SIM_HAL_KL34Z4_H__ - - -/*! - * @addtogroup sim_hal_kl34z4 - * @{ - */ -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - - /*! @brief COP clock source select */ -typedef enum _clock_cop_src_t -{ - kClockCopSrcLpoClk, /*!< LPO */ - kClockCopSrcAltClk, /*!< Alternative clock, for KL34Z4 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_cop_src_kl34z4_t; -#else -} clock_cop_src_t; -#endif - -/*! @brief TPM clock source select */ -typedef enum _clock_tpm_src -{ - kClockTpmSrcNone, /*!< clock disabled */ - kClockTpmSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTpmSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTpmSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tpm_src_kl34z4_t; -#else -} clock_tpm_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG out clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk, /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_kl34z4_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief UART0 clock source select */ -typedef enum _clock_lpsci_src -{ - kClockLpsciSrcNone, /*!< clock disabled */ - kClockLpsciSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockLpsciSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockLpsciSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lpsci_src_kl34z4_t; -#else -} clock_lpsci_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB clock source select */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< USB CLKIN Clock */ - kClockUsbfsSrcPllFllSel /*!< clock as selected by SOPT2[PLLFLLSEL] */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_kl34z4_t; -#else -} clock_usbfs_src_t; -#endif -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_kl34z4_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll, /*!< Fll clock */ - kClockPllFllSelPll /*!< Pll0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_kl34z4_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL) */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC 32k clock */ - kClockEr32kSrcReserved = 1U, /*!< Reserved */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock */ - kClockEr32kSrcLpo = 3U /*!< LPO clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_kl34z4_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutReserved = 0U, /*!< Reserved */ - kClockClkoutReserved1 = 1U, /*!< Reserved */ - kClockClkoutBusClk = 2U, /*!< Bus clock */ - kClockClkoutLpoClk = 3U, /*!< LPO clock */ - kClockClkoutMcgIrClk = 4U, /*!< MCG ir clock */ - kClockClkoutReserved2 = 5U, /*!< Reserved */ - kClockClkoutOsc0erClk = 6U, /*!< OSC0ER clock */ - kClockClkoutReserved3 = 7U /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_kl34z4_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz /*!< 32KHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_kl34z4_t; -#else -} clock_rtcout_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_kl34z4_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_kl34z4_t; -#else -} sim_usbvstby_mode_t; -#endif -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_kl34z4_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelComp0 = 1U, /*!< CMP0 output */ - kSimAdcTrgSelReserved = 2U, /*!< Reserved */ - kSimAdcTrgSelReserved1 = 3U, /*!< Reserved */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelReserved2 = 6U, /*!< Reserved */ - kSimAdcTrgSelReserved3 = 7U, /*!< Reserved */ - kSimAdcTrgSelTpm0 = 8U, /*!< TPM0 overflow */ - kSimAdcTrgSelTpm1 = 9U, /*!< TPM1 overflow */ - kSimAdcTrgSelTpm2 = 10U, /*!< TPM2 overflow */ - kSimAdcTrgSelReserved4 = 11U, /*!< Reserved */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U, /*!< Low-power timer trigger */ - kSimAdcTrgSelReserved5 = 15U /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_kl34z4_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_kl34z4_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcTpm1, /*!< UARTx_TX pin modulated with TPM1 channel 0 output */ - kSimUartTxsrcTpm2, /*!< UARTx_TX pin modulated with TPM2 channel 0 output */ - kSimUartTxsrcReserved /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_kl34z4_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM LPSCI receive data source select */ -typedef enum _sim_lpsci_rxsrc -{ - kSimLpsciRxsrcPin, /*!< LPSCIx_RX Pin */ - kSimLpsciRxsrcCmp0, /*!< CMP0 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpsci_rxsrc_kl34z4_t; -#else -} sim_lpsci_rxsrc_t; -#endif - -/*! @brief SIM LPSCI transmit data source select */ -typedef enum _sim_lpsci_txsrc -{ - kSimLpsciTxsrcPin, /*!< LPSCIx_TX Pin */ - kSimLpsciTxsrcTpm1, /*!< LPSCIx_TX pin modulated with TPM1 channel 0 output */ - kSimLpsciTxsrcTpm2, /*!< LPSCIx_TX pin modulated with TPM2 channel 0 output */ - kSimLpsciTxsrcReserved /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpsci_txsrc_kl34z4_t; -#else -} sim_lpsci_txsrc_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_kl34z4_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1, /*!< CMP0 output */ - kSimTpmChSrc2, /*!< Reserved */ - kSimTpmChSrc3 /*!< USB start of frame pulse */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_kl34z4_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateLpsci0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), -#endif - kSimClockGateCmp0 = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(4U, 22U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(4U, 23U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGateTsi0 = FSL_SIM_SCGC_BIT(5U, 5U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), -#if FSL_FEATURE_SOC_LCD_COUNT - kSimClockGateSlcd0 = FSL_SIM_SCGC_BIT(5U, 19U), -#endif - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateTpm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateTpm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateTpm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(6U, 31U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 8U) -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_kl34z4_t; -#else -} sim_clock_gate_name_t; -#endif - -/*@}*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTpmSrc(SIM_Type * base, - uint32_t instance, - clock_tpm_src_t setting) -{ - SIM_BWR_SOPT2_TPMSRC(base, setting); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_HAL_GetTpmSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_tpm_src_t)SIM_BRD_SOPT2_TPMSRC(base); -} - -/*! - * @brief Set the LPSCI clock source selection. - * - * This function sets the LPSCI clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetLpsciSrc(SIM_Type * base, - uint32_t instance, - clock_lpsci_src_t setting) -{ - SIM_BWR_SOPT2_UART0SRC(base, setting); -} - -/*! - * @brief Get the LPSCI clock source selection. - * - * This function gets the LPSCI clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_lpsci_src_t CLOCK_HAL_GetLpsciSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_lpsci_src_t)SIM_BRD_SOPT2_UART0SRC(base); -} -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -static inline void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - SIM_BWR_SOPT5_UART1RXSRC(base, select); -} - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -static inline sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); -} - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -static inline void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - SIM_BWR_SOPT5_UART1TXSRC(base, select); -} - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -static inline sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); -} - -/*! - * @brief Sets the LPSCIx receive data source select setting. - * - * This function selects the source for the LPSCIx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the LPSCIx receive data - */ -static inline void SIM_HAL_SetLpsciRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpsci_rxsrc_t select) -{ - SIM_BWR_SOPT5_UART0RXSRC(base, select); -} - -/*! - * @brief Gets the LPSCIx receive data source select setting. - * - * This function gets the LPSCIx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select LPSCIx receive data source select setting - */ -static inline sim_lpsci_rxsrc_t SIM_HAL_GetLpsciRxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_lpsci_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); -} - -/*! - * @brief Sets the LPSCIx transmit data source select setting. - * - * This function selects the source for the LPSCIx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the LPSCIx transmit data - */ -static inline void SIM_HAL_SetLpsciTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpsci_txsrc_t select) -{ - SIM_BWR_SOPT5_UART0TXSRC(base, select); -} - -/*! - * @brief Gets the LPSCIx transmit data source select setting. - * - * This function gets the LPSCIx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select LPSCIx transmit data source select setting - */ -static inline sim_lpsci_txsrc_t SIM_HAL_GetLpsciTxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_lpsci_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); -} - -#if FSL_FEATURE_SIM_OPT_HAS_ODE -/*! -* @brief Sets the UARTx Open Drain Enable setting. -* -* This function enables/disables the UARTx Open Drain. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @param enable Enable/disable UARTx Open Drain -* - True: Enable UARTx Open Drain -* - False: Disable UARTx Open Drain -*/ -void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable); - -/*! -* @brief Gets the UARTx Open Drain Enable setting. -* -* This function gets the UARTx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @return enabled True if UARTx Open Drain is enabled. -*/ -bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the LPSCIx Open Drain Enable setting. -* -* This function enables/disables the LPSCIx Open Drain. -* -* @param base Register base address of SIM. -* @param instance LPSCI instance. -* @param enable Enable/disable LPSCIx Open Drain -* - True: Enable LPSCIx Open Drain -* - False: Disable LPSCIx Open Drain -*/ -static inline void SIM_HAL_SetLpsciOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - SIM_BWR_SOPT5_UART0ODE(base, enable); -} - -/*! -* @brief Gets the LPSCIx Open Drain Enable setting. -* -* This function gets the LPSCIx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance LPSCI instance. -* @return enabled True if LPSCIx Open Drain is enabled. -*/ -static inline bool SIM_HAL_GetLpsciOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - return (bool)SIM_BRD_SOPT5_UART0ODE(base); -} -#endif - -#if FSL_FEATURE_SIM_OPT_HAS_TPM -/*! -* @brief Sets the Timer/PWM x external clock pin select setting. -* -* This function selects the source of the Timer/PWM x external clock pin select. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select Timer/PWM x external clock pin select -*/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select); - -/*! -* @brief Gets the Timer/PWM x external clock pin select setting. -* -* This function gets the Timer/PWM x external clock pin select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return Timer/PWM x external clock pin select setting -*/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the Timer/PWM x channel y input capture source select setting. -* -* This function selects the Timer/PWM x channel y input capture source. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @param select Timer/PWM x channel y input capture source -*/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select); - -/*! -* @brief Gets the Timer/PWM x channel y input capture source select setting. -* -* This function gets the Timer/PWM x channel y input capture source. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @return select Timer/PWM x channel y input capture source -*/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); -#endif - -/*! - * @brief Gets the Kinetis Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Family ID in the System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Family ID - */ -static inline uint32_t SIM_HAL_GetFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Sub-Family ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Sub-Family ID - */ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} - -/*! - * @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Series ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Series ID - */ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type * base) -{ - return SIM_BRD_SDID_SERIESID(base); -} - -/*! - * @brief Gets the Kinetis SramSize in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis SramSize in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis SramSize - */ -static inline uint32_t SIM_HAL_GetSramSize(SIM_Type * base) -{ - return SIM_BRD_SDID_SRAMSIZE(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the Kinetis Die ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Die ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Die ID - */ -static inline uint32_t SIM_HAL_GetDieId(SIM_Type * base) -{ - return SIM_BRD_SDID_DIEID(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_SIM_HAL_KL34Z4_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL36Z4/fsl_sim_hal_MKL36Z4.c b/KSDK_1.2.0/platform/hal/src/sim/MKL36Z4/fsl_sim_hal_MKL36Z4.c deleted file mode 100755 index 11e5e13..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL36Z4/fsl_sim_hal_MKL36Z4.c +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = 0U; - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable settingg - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, uint32_t instance, sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue =(sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - - if (altTrigEn) - { - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartOpenDrainCmd - * Description : Set UARTx Open Drain Enable setting - * This function will enable/disable the UARTx Open Drain. - * - *END**************************************************************************/ -void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 1: - SIM_BWR_SOPT5_UART1ODE(base, enable ? 1 : 0); - break; - case 2: - SIM_BWR_SOPT5_UART2ODE(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartOpenDrainCmd - * Description : Get UARTx Open Drain Enable setting - * This function will get UARTx Open Drain Enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 1: - retValue = SIM_BRD_SOPT5_UART1ODE(base); - break; - case 2: - retValue = SIM_BRD_SOPT5_UART2ODE(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmExternalClkPinSelMode - * Description : Set Timer/PWM x external clock pin select setting - * This function will select the source of Timer/PWM x external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_TPM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_TPM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_TPM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetTpmExternalClkPinSelMode - * Description : Get Timer/PWM x external clock pin select setting - * This function will get Timer/PWM x external clock pin select setting. - * - *END**************************************************************************/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance) -{ - sim_tpm_clk_sel_t retValue = (sim_tpm_clk_sel_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM0CLKSEL(base); - break; - case 1: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM1CLKSEL(base); - break; - case 2: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmChSrcMode - * Description : Timer/PWM x channel y input capture source select setting - * This function will select Timer/PWM x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - SIM_BWR_SOPT4_TPM1CH0SRC(base, select); - break; - case 2: - SIM_BWR_SOPT4_TPM2CH0SRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetTpmChSrcMode - * Description : Get Timer/PWM x channel y input capture source select setting - * This function will get Timer/PWM x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_tpm_ch_src_t retValue = (sim_tpm_ch_src_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM1CH0SRC(base); - break; - case 2: - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM2CH0SRC(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL36Z4/fsl_sim_hal_MKL36Z4.h b/KSDK_1.2.0/platform/hal/src/sim/MKL36Z4/fsl_sim_hal_MKL36Z4.h deleted file mode 100644 index 940ccdb..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL36Z4/fsl_sim_hal_MKL36Z4.h +++ /dev/null @@ -1,1397 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_KL36Z4_H__) -#define __FSL_SIM_HAL_KL36Z4_H__ - - -/*! - * @addtogroup sim_hal_kl36z4 - * @{ - */ -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - - /*! @brief COP clock source select */ -typedef enum _clock_cop_src_t -{ - kClockCopSrcLpoClk, /*!< LPO */ - kClockCopSrcAltClk, /*!< Alternative clock, for KL36Z4 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_cop_src_kl36z4_t; -#else -} clock_cop_src_t; -#endif - -/*! @brief TPM clock source select */ -typedef enum _clock_tpm_src -{ - kClockTpmSrcNone, /*!< clock disabled */ - kClockTpmSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTpmSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTpmSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tpm_src_kl36z4_t; -#else -} clock_tpm_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG out clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk, /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_kl36z4_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief UART0 clock source select */ -typedef enum _clock_lpsci_src -{ - kClockLpsciSrcNone, /*!< clock disabled */ - kClockLpsciSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockLpsciSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockLpsciSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lpsci_src_kl36z4_t; -#else -} clock_lpsci_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB clock source select */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< USB CLKIN Clock */ - kClockUsbfsSrcPllFllSel /*!< clock as selected by SOPT2[PLLFLLSEL] */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_kl36z4_t; -#else -} clock_usbfs_src_t; -#endif -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_kl36z4_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll, /*!< Fll clock */ - kClockPllFllSelPll /*!< Pll0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_kl36z4_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL) */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC 32k clock */ - kClockEr32kSrcReserved = 1U, /*!< Reserved */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock */ - kClockEr32kSrcLpo = 3U /*!< LPO clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_kl36z4_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutReserved = 0U, /*!< Reserved */ - kClockClkoutReserved1 = 1U, /*!< Reserved */ - kClockClkoutBusClk = 2U, /*!< Bus clock */ - kClockClkoutLpoClk = 3U, /*!< LPO clock */ - kClockClkoutMcgIrClk = 4U, /*!< MCG ir clock */ - kClockClkoutReserved2 = 5U, /*!< Reserved */ - kClockClkoutOsc0erClk = 6U, /*!< OSC0ER clock */ - kClockClkoutReserved3 = 7U /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_kl36z4_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz /*!< 32KHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_kl36z4_t; -#else -} clock_rtcout_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_kl36z4_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_kl36z4_t; -#else -} sim_usbvstby_mode_t; -#endif -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_kl36z4_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelComp0 = 1U, /*!< CMP0 output */ - kSimAdcTrgSelReserved = 2U, /*!< Reserved */ - kSimAdcTrgSelReserved1 = 3U, /*!< Reserved */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelReserved2 = 6U, /*!< Reserved */ - kSimAdcTrgSelReserved3 = 7U, /*!< Reserved */ - kSimAdcTrgSelTpm0 = 8U, /*!< TPM0 overflow */ - kSimAdcTrgSelTpm1 = 9U, /*!< TPM1 overflow */ - kSimAdcTrgSelTpm2 = 10U, /*!< TPM2 overflow */ - kSimAdcTrgSelReserved4 = 11U, /*!< Reserved */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U, /*!< Low-power timer trigger */ - kSimAdcTrgSelReserved5 = 15U /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_kl36z4_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_kl36z4_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcTpm1, /*!< UARTx_TX pin modulated with TPM1 channel 0 output */ - kSimUartTxsrcTpm2, /*!< UARTx_TX pin modulated with TPM2 channel 0 output */ - kSimUartTxsrcReserved /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_kl36z4_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM LPSCI receive data source select */ -typedef enum _sim_lpsci_rxsrc -{ - kSimLpsciRxsrcPin, /*!< LPSCIx_RX Pin */ - kSimLpsciRxsrcCmp0, /*!< CMP0 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpsci_rxsrc_kl36z4_t; -#else -} sim_lpsci_rxsrc_t; -#endif - -/*! @brief SIM LPSCI transmit data source select */ -typedef enum _sim_lpsci_txsrc -{ - kSimLpsciTxsrcPin, /*!< LPSCIx_TX Pin */ - kSimLpsciTxsrcTpm1, /*!< LPSCIx_TX pin modulated with TPM1 channel 0 output */ - kSimLpsciTxsrcTpm2, /*!< LPSCIx_TX pin modulated with TPM2 channel 0 output */ - kSimLpsciTxsrcReserved /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpsci_txsrc_kl36z4_t; -#else -} sim_lpsci_txsrc_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_kl36z4_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1, /*!< CMP0 output */ - kSimTpmChSrc2, /*!< Reserved */ - kSimTpmChSrc3 /*!< USB start of frame pulse */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_kl36z4_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateLpsci0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), -#endif - kSimClockGateCmp0 = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(4U, 22U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(4U, 23U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGateTsi0 = FSL_SIM_SCGC_BIT(5U, 5U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), -#if FSL_FEATURE_SOC_LCD_COUNT - kSimClockGateSlcd0 = FSL_SIM_SCGC_BIT(5U, 19U), -#endif - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateTpm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateTpm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateTpm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(6U, 31U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 8U) -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_kl36z4_t; -#else -} sim_clock_gate_name_t; -#endif - -/*@}*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTpmSrc(SIM_Type * base, - uint32_t instance, - clock_tpm_src_t setting) -{ - SIM_BWR_SOPT2_TPMSRC(base, setting); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_HAL_GetTpmSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_tpm_src_t)SIM_BRD_SOPT2_TPMSRC(base); -} - -/*! - * @brief Set the LPSCI clock source selection. - * - * This function sets the LPSCI clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetLpsciSrc(SIM_Type * base, - uint32_t instance, - clock_lpsci_src_t setting) -{ - SIM_BWR_SOPT2_UART0SRC(base, setting); -} - -/*! - * @brief Get the LPSCI clock source selection. - * - * This function gets the LPSCI clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_lpsci_src_t CLOCK_HAL_GetLpsciSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_lpsci_src_t)SIM_BRD_SOPT2_UART0SRC(base); -} -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -static inline void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - SIM_BWR_SOPT5_UART1RXSRC(base, select); -} - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -static inline sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); -} - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -static inline void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - SIM_BWR_SOPT5_UART1TXSRC(base, select); -} - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -static inline sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); -} - -/*! - * @brief Sets the LPSCIx receive data source select setting. - * - * This function selects the source for the LPSCIx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the LPSCIx receive data - */ -static inline void SIM_HAL_SetLpsciRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpsci_rxsrc_t select) -{ - SIM_BWR_SOPT5_UART0RXSRC(base, select); -} - -/*! - * @brief Gets the LPSCIx receive data source select setting. - * - * This function gets the LPSCIx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select LPSCIx receive data source select setting - */ -static inline sim_lpsci_rxsrc_t SIM_HAL_GetLpsciRxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_lpsci_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); -} - -/*! - * @brief Sets the LPSCIx transmit data source select setting. - * - * This function selects the source for the LPSCIx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the LPSCIx transmit data - */ -static inline void SIM_HAL_SetLpsciTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpsci_txsrc_t select) -{ - SIM_BWR_SOPT5_UART0TXSRC(base, select); -} - -/*! - * @brief Gets the LPSCIx transmit data source select setting. - * - * This function gets the LPSCIx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select LPSCIx transmit data source select setting - */ -static inline sim_lpsci_txsrc_t SIM_HAL_GetLpsciTxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_lpsci_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); -} - -#if FSL_FEATURE_SIM_OPT_HAS_ODE -/*! -* @brief Sets the UARTx Open Drain Enable setting. -* -* This function enables/disables the UARTx Open Drain. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @param enable Enable/disable UARTx Open Drain -* - True: Enable UARTx Open Drain -* - False: Disable UARTx Open Drain -*/ -void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable); - -/*! -* @brief Gets the UARTx Open Drain Enable setting. -* -* This function gets the UARTx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @return enabled True if UARTx Open Drain is enabled. -*/ -bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the LPSCIx Open Drain Enable setting. -* -* This function enables/disables the LPSCIx Open Drain. -* -* @param base Register base address of SIM. -* @param instance LPSCI instance. -* @param enable Enable/disable LPSCIx Open Drain -* - True: Enable LPSCIx Open Drain -* - False: Disable LPSCIx Open Drain -*/ -static inline void SIM_HAL_SetLpsciOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - SIM_BWR_SOPT5_UART0ODE(base, enable); -} - -/*! -* @brief Gets the LPSCIx Open Drain Enable setting. -* -* This function gets the LPSCIx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance LPSCI instance. -* @return enabled True if LPSCIx Open Drain is enabled. -*/ -static inline bool SIM_HAL_GetLpsciOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - return (bool)SIM_BRD_SOPT5_UART0ODE(base); -} -#endif - -#if FSL_FEATURE_SIM_OPT_HAS_TPM -/*! -* @brief Sets the Timer/PWM x external clock pin select setting. -* -* This function selects the source of the Timer/PWM x external clock pin select. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select Timer/PWM x external clock pin select -*/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select); - -/*! -* @brief Gets the Timer/PWM x external clock pin select setting. -* -* This function gets the Timer/PWM x external clock pin select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return Timer/PWM x external clock pin select setting -*/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the Timer/PWM x channel y input capture source select setting. -* -* This function selects the Timer/PWM x channel y input capture source. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @param select Timer/PWM x channel y input capture source -*/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select); - -/*! -* @brief Gets the Timer/PWM x channel y input capture source select setting. -* -* This function gets the Timer/PWM x channel y input capture source. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @return select Timer/PWM x channel y input capture source -*/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); -#endif - -/*! - * @brief Gets the Kinetis Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Family ID in the System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Family ID - */ -static inline uint32_t SIM_HAL_GetFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Sub-Family ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Sub-Family ID - */ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} - -/*! - * @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Series ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Series ID - */ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type * base) -{ - return SIM_BRD_SDID_SERIESID(base); -} - -/*! - * @brief Gets the Kinetis SramSize in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis SramSize in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis SramSize - */ -static inline uint32_t SIM_HAL_GetSramSize(SIM_Type * base) -{ - return SIM_BRD_SDID_SRAMSIZE(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the Kinetis Die ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Die ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Die ID - */ -static inline uint32_t SIM_HAL_GetDieId(SIM_Type * base) -{ - return SIM_BRD_SDID_DIEID(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_SIM_HAL_KL36Z4_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL43Z4/fsl_sim_hal_MKL43Z4.c b/KSDK_1.2.0/platform/hal/src/sim/MKL43Z4/fsl_sim_hal_MKL43Z4.c deleted file mode 100755 index 58799fb..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL43Z4/fsl_sim_hal_MKL43Z4.c +++ /dev/null @@ -1,384 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* -* Definitions -******************************************************************************/ - -/******************************************************************************* -* APIs -******************************************************************************/ - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_HAL_SetOutDiv -* Description : Set all clock out dividers setting at the same time -* This function will set the setting for all clock out dividers. -* -*END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = 0U; - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetLpuartSrc - * Description : Set the clock selection of LPUART. - * This function sets the clock selection of LPUART. - * - *END**************************************************************************/ -void CLOCK_HAL_SetLpuartSrc(SIM_Type * base, - uint32_t instance, - clock_lpuart_src_t setting) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0u == instance) - { - SIM_BWR_SOPT2_LPUART0SRC(base, setting); - } - else - { - SIM_BWR_SOPT2_LPUART1SRC(base, setting); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetLpuartSrc - * Description : Get the clock selection of LPUART. - * This function gets the clock selection of LPUART. - * - *END**************************************************************************/ -clock_lpuart_src_t CLOCK_HAL_GetLpuartSrc(SIM_Type * base, - uint32_t instance) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0u == instance) - { - return (clock_lpuart_src_t)SIM_BRD_SOPT2_LPUART0SRC(base); - } - else - { - return (clock_lpuart_src_t)SIM_BRD_SOPT2_LPUART1SRC(base); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmChSrcMode - * Description : Sets the Timer/PWM x channel y input capture source. - * - *END**************************************************************************/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select) -{ - assert(instance < TPM_INSTANCE_COUNT); - - if(instance == 1) - { - SIM_BWR_SOPT4_TPM1CH0SRC(base, select); - } - else if(instance == 2) - { - SIM_BWR_SOPT4_TPM2CH0SRC(base, select); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmChSrcMode - * Description : Sets the Timer/PWM x channel y input capture source. - * - *END**************************************************************************/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - assert(instance < TPM_INSTANCE_COUNT); - - sim_tpm_ch_src_t retValue = (sim_tpm_ch_src_t)0; - - if(instance == 1) - { - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM1CH0SRC(base); - } - else if(instance == 2) - { - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM2CH0SRC(base); - } - - return retValue; -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetLpuartRxSrcMode -* Description : Sets the LPUARTx receive data source select setting. -* -*END**************************************************************************/ -void SIM_HAL_SetLpuartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpuart_rxsrc_t select) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - SIM_BWR_SOPT5_LPUART0RXSRC(base, select); - } - else - { - SIM_BWR_SOPT5_LPUART1RXSRC(base, select); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_GetLpuartRxSrcMode -* Description : Gets the LPUARTx receive data source select setting. -* -*END**************************************************************************/ -sim_lpuart_rxsrc_t SIM_HAL_GetLpuartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - return (sim_lpuart_rxsrc_t)SIM_BRD_SOPT5_LPUART0RXSRC(base); - } - else - { - return (sim_lpuart_rxsrc_t)SIM_BRD_SOPT5_LPUART1RXSRC(base); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetLpuartTxSrcMode -* Description : Sets the LPUARTx transmit data source select setting. -* -*END**************************************************************************/ -void SIM_HAL_SetLpuartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpuart_txsrc_t select) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - SIM_BWR_SOPT5_LPUART0TXSRC(base, select); - } - else - { - SIM_BWR_SOPT5_LPUART1TXSRC(base, select); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetLpuartTxSrcMode -* Description : Sets the LPUARTx transmit data source select setting. -* -*END**************************************************************************/ -sim_lpuart_txsrc_t SIM_HAL_GetLpuartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - return (sim_lpuart_txsrc_t)SIM_BRD_SOPT5_LPUART0TXSRC(base); - } - else - { - return (sim_lpuart_txsrc_t)SIM_BRD_SOPT5_LPUART1TXSRC(base); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetLpuartOpenDrainCmd -* Description : This function enables/disables the LPUARTx Open Drain. -* -*END**************************************************************************/ -void SIM_HAL_SetLpuartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - SIM_BWR_SOPT5_LPUART0ODE(base, enable ? 1 : 0); - } - else - { - SIM_BWR_SOPT5_LPUART1ODE(base, enable ? 1 : 0); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_GetLpuartOpenDrainCmd -* Description : This function gets the LPUARTx Open Drain setting. -* -*END**************************************************************************/ -bool SIM_HAL_GetLpuartOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - assert(instance < LPUART_INSTANCE_COUNT); - - if (0 == instance) - { - return (bool)SIM_BRD_SOPT5_LPUART0ODE(base); - } - else - { - return (bool)SIM_BRD_SOPT5_LPUART1ODE(base); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetAdcTriggerModeOneStep -* Description : Set ADCx trigger setting. -* This function sets ADC alternate trigger, pre-trigger mode and trigger mode. -* -*END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - - if (altTrigEn) - { - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - } - -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_SetTpmExternalClkPinSelMode -* Description : Set Timer/PWM x external clock pin select setting -* This function will select the source of Timer/PWM x external clock pin select -* -*END**************************************************************************/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_TPM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_TPM1CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_GetTpmExternalClkPinSelMode -* Description : Get Timer/PWM x external clock pin select setting -* This function will get Timer/PWM x external clock pin select setting. -* -*END**************************************************************************/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance) -{ - sim_tpm_clk_sel_t retValue = (sim_tpm_clk_sel_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM0CLKSEL(base); - break; - case 1: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM1CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* -* EOF -******************************************************************************/ diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL43Z4/fsl_sim_hal_MKL43Z4.h b/KSDK_1.2.0/platform/hal/src/sim/MKL43Z4/fsl_sim_hal_MKL43Z4.h deleted file mode 100644 index fe67afd..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL43Z4/fsl_sim_hal_MKL43Z4.h +++ /dev/null @@ -1,1371 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#if !defined(__FSL_SIM_HAL_MKL43Z4_H__) -#define __FSL_SIM_HAL_MKL43Z4_H__ - - -/*! - * @addtogroup sim_hal_kl43z4 - * @{ - */ -/*! @file*/ - -/******************************************************************************* -* Definitions -******************************************************************************/ -/*! @brief COP clock source selection.*/ -typedef enum _clock_cop_src { - kClockCopSrcLpoClk, /*!< LPO clock 1K HZ.*/ - kClockCopSrcMcgIrClk, /*!< MCG IRC Clock */ - kClockCopSrcOsc0erClk, /*!< OSCER Clock */ - kClockCopSrcBusClk /*!< BUS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -}clock_cop_src_kl43z4_t; -#else -}clock_cop_src_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U, /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_kl43z4_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM external reference clock output pin select (OSC32KOUT). */ -typedef enum _clock_osc32kout_sel -{ - kClockOsc32koutNone = 0U, /*!< ERCLK32K is not output. */ - kClockOsc32koutPte0 = 1U, /*!< ERCLK32K is output on PTE0. */ - kClockOsc32koutPte26 = 2U, /*!< ERCLK32K is output on PTE26. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_osc32kout_sel_kl43z4_t; -#else -} clock_osc32kout_sel_t; -#endif - -/*! @brief SIM LPUART clock source */ -typedef enum _clock_lpuart_src -{ - kClockLpuartSrcNone, /*!< disabled */ - kClockLpuartSrcIrc48M, /*!< IRC48M */ - kClockLpuartSrcOsc0erClk, /*!< OSCER clock */ - kClockLpuartSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lpuart_src_kl43z4_t; -#else -} clock_lpuart_src_t; -#endif - -/*! @brief SIM TPM clock source */ -typedef enum _clock_tpm_src -{ - kClockTpmSrcNone, /*!< disabled */ - kClockTpmSrcIrc48M, /*!< IRC48M/MCGPCLK */ - kClockTpmSrcOsc0erClk, /*!< OSCER clock */ - kClockTpmSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tpm_src_kl43z4_t; -#else -} clock_tpm_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcIrc48M, /*!< IRC48/MCGPCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_kl43z4_t; -#else -} clock_usbfs_src_t; -#endif -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! @brief FLEXIO clock source. */ -typedef enum _clock_flexio_src -{ - kClockFlexioSrcNone, /*!< Clock disabled. */ - kClockFlexioSrcIrc48M, /*!< MCGPCLK/IRC48M. */ - kClockFlexioSrcOsc0erClk, /*!< OSCERCLK. */ - kClockFlexioSrcMcgIrClk, /*!< MCGIRCLK. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_flexio_src_kl43z4_t; -#else -} clock_flexio_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG out clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk, /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_kl43z4_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCG out clock */ - kClockClkoutSelOsc0erClk = 6U, /*!< OSCER clock */ - kClockClkoutSelIrc48M = 7U /*!< IRC48M clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_kl43z4_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrcOsc0erClk, /*!< OSCER clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_kl43z4_t; -#else -} clock_rtcout_src_t; -#endif - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_kl43z4_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelComp0 = 1U, /*!< CMP0 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelTpm0 = 8U, /*!< TPM0 overflow */ - kSimAdcTrgSelTpm1 = 9U, /*!< TPM1 overflow */ - kSimAdcTrgSelTpm2 = 10U, /*!< TPM2 overflow */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U, /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_kl43z4_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief LPUART receive data source. */ -typedef enum _sim_lpuart_rxsrc -{ - kSimLpuartRxsrcPin, /*!< LPUARTx_RX Pin */ - kSimLpuartRxsrcCmp0, /*!< CMP0 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpuart_rxsrc_kl43z4_t; -#else -} sim_lpuart_rxsrc_t; -#endif - -/*! @brief LPUART transmit data source. */ -typedef enum _sim_lpuart_txsrc -{ - kSimLpuartTxsrcPin, /*!< UARTx_TX Pin */ - kSimLpuartTxsrcTpm1, /*!< UARTx_TX pin modulated with TPM1 channel 0 output */ - kSimLpuartTxsrcTpm2, /*!< UARTx_TX pin modulated with TPM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpuart_txsrc_kl43z4_t; -#else -} sim_lpuart_txsrc_t; -#endif - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcMcgIrClk = 2U, /*!< MCGIRCLK */ - kClockSaiSrcIrc48M = 3U, /*!< MCGPCLK/IRC48M. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_kl43z4_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_kl43z4_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< Channel y input capture source uses 0. */ - kSimTpmChSrc1, /*!< Channel y input capture source uses 1. */ - kSimTpmChSrc2, /*!< Channel y input capture source uses 2. */ - kSimTpmChSrc3, /*!< Channel y input capture source uses 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_kl43z4_t; -#else -} sim_tpm_ch_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_kl43z4_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_kl43z4_t; -#else -} sim_usbvstby_mode_t; -#endif -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), -#endif - kSimClockGateCmp0 = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(4U, 22U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(4U, 23U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), -#if FSL_FEATURE_SOC_LCD_COUNT - kSimClockGateSlcd0 = FSL_SIM_SCGC_BIT(5U, 19U), -#endif - kSimClockGateLpuart0 = FSL_SIM_SCGC_BIT(5U, 20U), - kSimClockGateLpuart1 = FSL_SIM_SCGC_BIT(5U, 21U), - kSimClockGateFlexio0 = FSL_SIM_SCGC_BIT(5U, 31U), - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateTpm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateTpm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateTpm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(6U, 31U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 8U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_kl43z4_t; -#else -} sim_clock_gate_name_t; -#endif - -/*@}*/ - -/******************************************************************************* -* API -******************************************************************************/ -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! -* @brief Disable the clock for specific module. -* -* This function disables the clock for specific module. -* -* @param base Base address for current SIM instance. -* @param name Name of the module to disable. -*/ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! -* @brief Get the the clock gate state for specific module. -* -* This function will get the clock gate state for specific module. -* -* @param base Base address for current SIM instance. -* @param name Name of the module to get. -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! -* @brief Set the clock selection of LPUART. -* -* This function sets the clock selection of LPUART. -* -* @param base Base address for current SIM instance. -* @param instance LPUART instance. -* @param setting The value to set. -*/ -void CLOCK_HAL_SetLpuartSrc(SIM_Type * base, - uint32_t instance, - clock_lpuart_src_t setting); - -/*! -* @brief Get the clock selection of LPUART. -* -* This function gets the clock selection of LPUART. -* -* @param base Base address for current SIM instance. -* @param instance LPUART instance. -* @return Current selection. -*/ -clock_lpuart_src_t CLOCK_HAL_GetLpuartSrc(SIM_Type * base, - uint32_t instance); - -/*! -* @brief Set the clock selection of TPM. -* -* This function sets the clock selection of TPM. -* -* @param base Base address for current SIM instance. -* @param instance IP instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetTpmSrc(SIM_Type * base, - uint32_t instance, - clock_tpm_src_t setting) -{ - SIM_BWR_SOPT2_TPMSRC(base, setting); -} - -/*! -* @brief Get the clock selection of TPM. -* -* This function gets the clock selection of TPM. -* -* @param base Base address for current SIM instance. -* @param instance IP instance. -* @return Current selection. -*/ -static inline clock_tpm_src_t CLOCK_HAL_GetTpmSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_tpm_src_t)SIM_BRD_SOPT2_TPMSRC(base); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Select the clock source for FLEXIO. - * - * This function selects the clock source for FLEXIO. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetFlexioSrc(SIM_Type * base, - uint32_t instance, - clock_flexio_src_t setting) -{ - SIM_BWR_SOPT2_FLEXIOSRC(base, setting); -} - -/*! - * @brief Get the clock source of FLEXIO. - * - * This function gets the clock source of FLEXIO. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_flexio_src_t CLOCK_HAL_GetFlexioSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_flexio_src_t)SIM_BRD_SOPT2_FLEXIOSRC(base); -} - -/*! -* @brief Set the clock ERCLK32K output on selected pin. -* -* This function sets ERCLK32K output on selected pin. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetOsc32kOutSel(SIM_Type * base, - clock_osc32kout_sel_t setting) -{ - SIM_BWR_SOPT1_OSC32KOUT(base, setting); -} - -/*! -* @brief Get output status of ERCLK32K. -* -* This function gets the output status of ERCLK32K. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_osc32kout_sel_t CLOCK_HAL_GetOsc32kOutSel(SIM_Type * base) -{ - return (clock_osc32kout_sel_t)SIM_BRD_SOPT1_OSC32KOUT(base); -} - - -/*! -* @brief Set the clock selection of ERCLK32K. -* -* This function sets the clock selection of ERCLK32K. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! -* @brief Get the clock selection of ERCLK32K. -* -* This function gets the clock selection of ERCLK32K. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! -* @brief Set CLKOUTSEL selection. -* -* This function sets the selection of the clock to output on the CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! -* @brief Get CLKOUTSEL selection. -* -* This function gets the selection of the clock to output on the CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! -* @brief Set RTCCLKOUTSEL selection. -* -* This function sets the selection of the clock to output on the RTC_CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! -* @brief Get RTCCLKOUTSEL selection. -* -* This function gets the selection of the clock to output on the RTC_CLKOUT pin. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - - -/*! -* @brief Set the clock selection of COP. -* -* This function sets the clock selection of COP. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetCopSrc(SIM_Type * base, - clock_cop_src_t setting) -{ - SIM_BWR_COPC_COPCLKSEL(base, setting); -} - -/*! -* @brief Get the clock selection of COP. -* -* This function gets the clock selection of COP. -* -* @param base Base address for current SIM instance. -* @return Current selection. -*/ -static inline clock_cop_src_t CLOCK_HAL_GetCopSrc(SIM_Type * base) -{ - return (clock_cop_src_t)SIM_BRD_COPC_COPCLKSEL(base); -} - - -/*! -* @brief Set OUTDIV1. -* -* This function sets divide value OUTDIV1. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! -* @brief Get OUTDIV1. -* -* This function gets divide value OUTDIV1. -* -* @param base Base address for current SIM instance. -* @return Current divide value. -*/ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! -* @brief Set OUTDIV4. -* -* This function sets divide value OUTDIV4. -* -* @param base Base address for current SIM instance. -* @param setting The value to set. -*/ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! -* @brief Get OUTDIV4. -* -* This function gets divide value OUTDIV4. -* -* @param base Base address for current SIM instance. -* @return Current divide value. -*/ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif //FSL_FEATURE_SOC_USB_COUNT - -/*! -* @brief Sets the ADCx alternate trigger enable setting. -* -* This function enables/disables the alternative conversion triggers for ADCx. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param enable Enable alternative conversion triggers for ADCx -* - true: Select alternative conversion trigger. -* - false: Select PDB trigger. -*/ -static inline void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - -} - -/*! -* @brief Gets the ADCx alternate trigger enable setting. -* -* This function gets the ADCx alternate trigger enable setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return enabled True if ADCx alternate trigger is enabled -*/ - -static inline bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - - return retValue; -} - -/*! -* @brief Sets the ADCx pre-trigger select setting. -* -* This function selects the ADCx pre-trigger source when the alternative -* triggers are enabled through ADCxALTTRGEN. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select pre-trigger select setting for ADCx -*/ -static inline void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - -} -/*! -* @brief Gets the ADCx pre-trigger select setting. -* -* This function gets the ADCx pre-trigger select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return select ADCx pre-trigger select setting -*/ -static inline sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - - return retValue; -} - -/*! -* @brief Sets the ADCx trigger select setting. -* -* This function selects the ADCx trigger source when alternative triggers -* are enabled through ADCxALTTRGEN. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select trigger select setting for ADCx -*/ -static inline void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - -} - -/*! -* @brief Gets the ADCx trigger select setting. -* -* This function gets the ADCx trigger select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return ADCx trigger select setting -*/ -static inline sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - - return retValue; -} - -/*! -* @brief Sets the ADCx trigger select setting in one function. -* -* This function sets ADC alternate trigger, pre-trigger mode and trigger mode. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param altTrigEn Alternative trigger enable or not. -* @param preTrigSel Pre-trigger mode. -* @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! -* @brief Sets the LPUARTx receive data source select setting. -* -* This function selects the source for the LPUARTx receive data. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @param select the source for the LPUARTx receive data -*/ -void SIM_HAL_SetLpuartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpuart_rxsrc_t select); - -/*! -* @brief Gets the LPUARTx receive data source select setting. -* -* This function gets the LPUARTx receive data source select setting. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* -* @return select UARTx receive data source select setting -*/ -sim_lpuart_rxsrc_t SIM_HAL_GetLpuartRxSrcMode(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the LPUARTx transmit data source select setting. -* -* This function selects the source for the LPUARTx transmit data. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @param select the source for the UARTx transmit data. -*/ -void SIM_HAL_SetLpuartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpuart_txsrc_t select); - -/*! -* @brief Gets the LPUARTx transmit data source select setting. -* -* This function gets the LPUARTx transmit data source select setting. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @return select UARTx transmit data source select setting. -*/ -sim_lpuart_txsrc_t SIM_HAL_GetLpuartTxSrcMode(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the LPUARTx Open Drain Enable setting. -* -* This function enables/disables the LPUARTx Open Drain. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @param enable Enable/disable LPUARTx Open Drain -* - True: Enable LPUARTx Open Drain -* - False: Disable LPUARTx Open Drain -*/ -void SIM_HAL_SetLpuartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable); - -/*! -* @brief Gets the LPUARTx Open Drain Enable setting. -* -* This function gets the LPUARTx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance LPUART instance. -* @return enabled True if LPUARTx Open Drain is enabled. -*/ -bool SIM_HAL_GetLpuartOpenDrainCmd(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the UARTx Open Drain Enable setting. -* -* This function enables/disables the UARTx Open Drain. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @param enable Enable/disable UARTx Open Drain -* - True: Enable UARTx Open Drain -* - False: Disable UARTx Open Drain -*/ -static inline void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - // Only support UART2 - assert (2 == instance); - SIM_BWR_SOPT5_UART2ODE(base, enable ? 1 : 0); -} - -/*! -* @brief Gets the UARTx Open Drain Enable setting. -* -* This function gets the UARTx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @return enabled True if UARTx Open Drain is enabled. -*/ -static inline bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, - uint32_t instance) -{ - // Only support UART2 - assert (2 == instance); - return (bool)SIM_BRD_SOPT5_UART2ODE(base); -} - -/*! -* @brief Sets the Timer/PWM x channel y input capture source select setting. -* -* This function selects the Timer/PWM x channel y input capture source. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @param select Timer/PWM x channel y input capture source -*/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select); - -/*! -* @brief Gets the Timer/PWM x channel y input capture source select setting. -* -* This function gets the Timer/PWM x channel y input capture source select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel Tpm channel y -* @return select Timer/PWM x channel y input capture source select setting -*/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! -* @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Sub-Family ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Sub-Family ID -*/ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} - -/*! -* @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Series ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Series ID -*/ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type * base) -{ - return SIM_BRD_SDID_SERIESID(base); -} - -/*! -* @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Fam ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Fam ID -*/ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! -* @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Pincount ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Pincount ID -*/ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! -* @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). -* -* This function gets the Kinetis Revision ID in System Device ID register. -* -* @param base Base address for current SIM instance. -* @return id Kinetis Revision ID -*/ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! -* @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function gets the program flash size in the Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @return size Program flash Size -*/ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! -* @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function sets the Flash Doze in the Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @param setting Flash Doze setting -*/ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! -* @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function gets the Flash Doze in the Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @return setting Flash Doze setting -*/ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! -* @brief Sets the Flash disable setting. -* -* This function sets the Flash disable setting in the -* Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @param disable Flash disable setting -*/ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! -* @brief Gets the Flash disable setting. -* -* This function gets the Flash disable setting in the -* Flash Configuration Register 1. -* -* @param base Base address for current SIM instance. -* @return setting Flash disable setting -*/ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! -* @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). -* -* This function gets the Flash maximum block 0 in Flash Configuration Register 2. -* -* @param base Base address for current SIM instance. -* @return address Flash maximum block 0 address -*/ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -/*! -* @brief Sets the Timer/PWM x external clock pin select setting. -* -* This function selects the source of the Timer/PWM x external clock pin select. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select Timer/PWM x external clock pin select -* - 0: Timer/PWM x external clock driven by the TPM_CLKIN0 pin. -* - 1: Timer/PWM x external clock driven by the TPM_CLKIN1 pin. -*/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select); - -/*! -* @brief Gets the Timer/PWM x external clock pin select setting. -* -* This function gets the Timer/PWM x external clock pin select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return select Timer/PWM x external clock pin select setting -*/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance); - - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_SIM_HAL_MKL43Z4_H__*/ -/******************************************************************************* -* EOF -******************************************************************************/ diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL46Z4/fsl_sim_hal_MKL46Z4.c b/KSDK_1.2.0/platform/hal/src/sim/MKL46Z4/fsl_sim_hal_MKL46Z4.c deleted file mode 100755 index 11e5e13..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL46Z4/fsl_sim_hal_MKL46Z4.c +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = 0U; - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable settingg - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, uint32_t instance, sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue =(sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - - if (altTrigEn) - { - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartOpenDrainCmd - * Description : Set UARTx Open Drain Enable setting - * This function will enable/disable the UARTx Open Drain. - * - *END**************************************************************************/ -void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 1: - SIM_BWR_SOPT5_UART1ODE(base, enable ? 1 : 0); - break; - case 2: - SIM_BWR_SOPT5_UART2ODE(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartOpenDrainCmd - * Description : Get UARTx Open Drain Enable setting - * This function will get UARTx Open Drain Enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 1: - retValue = SIM_BRD_SOPT5_UART1ODE(base); - break; - case 2: - retValue = SIM_BRD_SOPT5_UART2ODE(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmExternalClkPinSelMode - * Description : Set Timer/PWM x external clock pin select setting - * This function will select the source of Timer/PWM x external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_TPM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_TPM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_TPM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetTpmExternalClkPinSelMode - * Description : Get Timer/PWM x external clock pin select setting - * This function will get Timer/PWM x external clock pin select setting. - * - *END**************************************************************************/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance) -{ - sim_tpm_clk_sel_t retValue = (sim_tpm_clk_sel_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM0CLKSEL(base); - break; - case 1: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM1CLKSEL(base); - break; - case 2: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmChSrcMode - * Description : Timer/PWM x channel y input capture source select setting - * This function will select Timer/PWM x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - SIM_BWR_SOPT4_TPM1CH0SRC(base, select); - break; - case 2: - SIM_BWR_SOPT4_TPM2CH0SRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetTpmChSrcMode - * Description : Get Timer/PWM x channel y input capture source select setting - * This function will get Timer/PWM x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_tpm_ch_src_t retValue = (sim_tpm_ch_src_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM1CH0SRC(base); - break; - case 2: - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM2CH0SRC(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKL46Z4/fsl_sim_hal_MKL46Z4.h b/KSDK_1.2.0/platform/hal/src/sim/MKL46Z4/fsl_sim_hal_MKL46Z4.h deleted file mode 100644 index 6c7fb45..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKL46Z4/fsl_sim_hal_MKL46Z4.h +++ /dev/null @@ -1,1397 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_KL46Z4_H__) -#define __FSL_SIM_HAL_KL46Z4_H__ - - -/*! - * @addtogroup sim_hal_kl46z4 - * @{ - */ -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - - /*! @brief COP clock source select */ -typedef enum _clock_cop_src_t -{ - kClockCopSrcLpoClk, /*!< LPO */ - kClockCopSrcAltClk, /*!< Alternative clock, for KL46Z4 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_cop_src_kl46z4_t; -#else -} clock_cop_src_t; -#endif - -/*! @brief TPM clock source select */ -typedef enum _clock_tpm_src -{ - kClockTpmSrcNone, /*!< clock disabled */ - kClockTpmSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTpmSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTpmSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tpm_src_kl46z4_t; -#else -} clock_tpm_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG out clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk, /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_kl46z4_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief UART0 clock source select */ -typedef enum _clock_lpsci_src -{ - kClockLpsciSrcNone, /*!< clock disabled */ - kClockLpsciSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockLpsciSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockLpsciSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lpsci_src_kl46z4_t; -#else -} clock_lpsci_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB clock source select */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< USB CLKIN Clock */ - kClockUsbfsSrcPllFllSel /*!< clock as selected by SOPT2[PLLFLLSEL] */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_kl46z4_t; -#else -} clock_usbfs_src_t; -#endif -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_kl46z4_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll, /*!< Fll clock */ - kClockPllFllSelPll /*!< Pll0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_kl46z4_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL) */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC 32k clock */ - kClockEr32kSrcReserved = 1U, /*!< Reserved */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock */ - kClockEr32kSrcLpo = 3U /*!< LPO clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_kl46z4_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutReserved = 0U, /*!< Reserved */ - kClockClkoutReserved1 = 1U, /*!< Reserved */ - kClockClkoutBusClk = 2U, /*!< Bus clock */ - kClockClkoutLpoClk = 3U, /*!< LPO clock */ - kClockClkoutMcgIrClk = 4U, /*!< MCG ir clock */ - kClockClkoutReserved2 = 5U, /*!< Reserved */ - kClockClkoutOsc0erClk = 6U, /*!< OSC0ER clock */ - kClockClkoutReserved3 = 7U /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_kl46z4_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz /*!< 32KHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_kl46z4_t; -#else -} clock_rtcout_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_kl46z4_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_kl46z4_t; -#else -} sim_usbvstby_mode_t; -#endif -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_kl46z4_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelComp0 = 1U, /*!< CMP0 output */ - kSimAdcTrgSelReserved = 2U, /*!< Reserved */ - kSimAdcTrgSelReserved1 = 3U, /*!< Reserved */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelReserved2 = 6U, /*!< Reserved */ - kSimAdcTrgSelReserved3 = 7U, /*!< Reserved */ - kSimAdcTrgSelTpm0 = 8U, /*!< TPM0 overflow */ - kSimAdcTrgSelTpm1 = 9U, /*!< TPM1 overflow */ - kSimAdcTrgSelTpm2 = 10U, /*!< TPM2 overflow */ - kSimAdcTrgSelReserved4 = 11U, /*!< Reserved */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U, /*!< Low-power timer trigger */ - kSimAdcTrgSelReserved5 = 15U /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_kl46z4_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_kl46z4_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcTpm1, /*!< UARTx_TX pin modulated with TPM1 channel 0 output */ - kSimUartTxsrcTpm2, /*!< UARTx_TX pin modulated with TPM2 channel 0 output */ - kSimUartTxsrcReserved /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_kl46z4_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM LPSCI receive data source select */ -typedef enum _sim_lpsci_rxsrc -{ - kSimLpsciRxsrcPin, /*!< LPSCIx_RX Pin */ - kSimLpsciRxsrcCmp0, /*!< CMP0 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpsci_rxsrc_kl46z4_t; -#else -} sim_lpsci_rxsrc_t; -#endif - -/*! @brief SIM LPSCI transmit data source select */ -typedef enum _sim_lpsci_txsrc -{ - kSimLpsciTxsrcPin, /*!< LPSCIx_TX Pin */ - kSimLpsciTxsrcTpm1, /*!< LPSCIx_TX pin modulated with TPM1 channel 0 output */ - kSimLpsciTxsrcTpm2, /*!< LPSCIx_TX pin modulated with TPM2 channel 0 output */ - kSimLpsciTxsrcReserved /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpsci_txsrc_kl46z4_t; -#else -} sim_lpsci_txsrc_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_kl46z4_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1, /*!< CMP0 output */ - kSimTpmChSrc2, /*!< Reserved */ - kSimTpmChSrc3 /*!< USB start of frame pulse */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_kl46z4_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateLpsci0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), -#endif - kSimClockGateCmp0 = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(4U, 22U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(4U, 23U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGateTsi0 = FSL_SIM_SCGC_BIT(5U, 5U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), -#if FSL_FEATURE_SOC_LCD_COUNT - kSimClockGateSlcd0 = FSL_SIM_SCGC_BIT(5U, 19U), -#endif - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateTpm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateTpm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateTpm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(6U, 31U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 8U) -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_kl46z4_t; -#else -} sim_clock_gate_name_t; -#endif - -/*@}*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTpmSrc(SIM_Type * base, - uint32_t instance, - clock_tpm_src_t setting) -{ - SIM_BWR_SOPT2_TPMSRC(base, setting); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_HAL_GetTpmSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_tpm_src_t)SIM_BRD_SOPT2_TPMSRC(base); -} - -/*! - * @brief Set the LPSCI clock source selection. - * - * This function sets the LPSCI clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetLpsciSrc(SIM_Type * base, - uint32_t instance, - clock_lpsci_src_t setting) -{ - SIM_BWR_SOPT2_UART0SRC(base, setting); -} - -/*! - * @brief Get the LPSCI clock source selection. - * - * This function gets the LPSCI clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_lpsci_src_t CLOCK_HAL_GetLpsciSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_lpsci_src_t)SIM_BRD_SOPT2_UART0SRC(base); -} -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -static inline void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - SIM_BWR_SOPT5_UART1RXSRC(base, select); -} - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -static inline sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); -} - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -static inline void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - SIM_BWR_SOPT5_UART1TXSRC(base, select); -} - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -static inline sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); -} - -/*! - * @brief Sets the LPSCIx receive data source select setting. - * - * This function selects the source for the LPSCIx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the LPSCIx receive data - */ -static inline void SIM_HAL_SetLpsciRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpsci_rxsrc_t select) -{ - SIM_BWR_SOPT5_UART0RXSRC(base, select); -} - -/*! - * @brief Gets the LPSCIx receive data source select setting. - * - * This function gets the LPSCIx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select LPSCIx receive data source select setting - */ -static inline sim_lpsci_rxsrc_t SIM_HAL_GetLpsciRxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_lpsci_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); -} - -/*! - * @brief Sets the LPSCIx transmit data source select setting. - * - * This function selects the source for the LPSCIx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the LPSCIx transmit data - */ -static inline void SIM_HAL_SetLpsciTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpsci_txsrc_t select) -{ - SIM_BWR_SOPT5_UART0TXSRC(base, select); -} - -/*! - * @brief Gets the LPSCIx transmit data source select setting. - * - * This function gets the LPSCIx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select LPSCIx transmit data source select setting - */ -static inline sim_lpsci_txsrc_t SIM_HAL_GetLpsciTxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_lpsci_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); -} - -#if FSL_FEATURE_SIM_OPT_HAS_ODE -/*! -* @brief Sets the UARTx Open Drain Enable setting. -* -* This function enables/disables the UARTx Open Drain. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @param enable Enable/disable UARTx Open Drain -* - True: Enable UARTx Open Drain -* - False: Disable UARTx Open Drain -*/ -void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable); - -/*! -* @brief Gets the UARTx Open Drain Enable setting. -* -* This function gets the UARTx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @return enabled True if UARTx Open Drain is enabled. -*/ -bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the LPSCIx Open Drain Enable setting. -* -* This function enables/disables the LPSCIx Open Drain. -* -* @param base Register base address of SIM. -* @param instance LPSCI instance. -* @param enable Enable/disable LPSCIx Open Drain -* - True: Enable LPSCIx Open Drain -* - False: Disable LPSCIx Open Drain -*/ -static inline void SIM_HAL_SetLpsciOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - SIM_BWR_SOPT5_UART0ODE(base, enable); -} - -/*! -* @brief Gets the LPSCIx Open Drain Enable setting. -* -* This function gets the LPSCIx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance LPSCI instance. -* @return enabled True if LPSCIx Open Drain is enabled. -*/ -static inline bool SIM_HAL_GetLpsciOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - return (bool)SIM_BRD_SOPT5_UART0ODE(base); -} -#endif - -#if FSL_FEATURE_SIM_OPT_HAS_TPM -/*! -* @brief Sets the Timer/PWM x external clock pin select setting. -* -* This function selects the source of the Timer/PWM x external clock pin select. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select Timer/PWM x external clock pin select -*/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select); - -/*! -* @brief Gets the Timer/PWM x external clock pin select setting. -* -* This function gets the Timer/PWM x external clock pin select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return Timer/PWM x external clock pin select setting -*/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the Timer/PWM x channel y input capture source select setting. -* -* This function selects the Timer/PWM x channel y input capture source. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @param select Timer/PWM x channel y input capture source -*/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select); - -/*! -* @brief Gets the Timer/PWM x channel y input capture source select setting. -* -* This function gets the Timer/PWM x channel y input capture source. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @return select Timer/PWM x channel y input capture source -*/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); -#endif - -/*! - * @brief Gets the Kinetis Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Family ID in the System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Family ID - */ -static inline uint32_t SIM_HAL_GetFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Sub-Family ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Sub-Family ID - */ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} - -/*! - * @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Series ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Series ID - */ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type * base) -{ - return SIM_BRD_SDID_SERIESID(base); -} - -/*! - * @brief Gets the Kinetis SramSize in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis SramSize in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis SramSize - */ -static inline uint32_t SIM_HAL_GetSramSize(SIM_Type * base) -{ - return SIM_BRD_SDID_SRAMSIZE(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the Kinetis Die ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Die ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Die ID - */ -static inline uint32_t SIM_HAL_GetDieId(SIM_Type * base) -{ - return SIM_BRD_SDID_DIEID(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_SIM_HAL_KL46Z4_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKV10Z7/fsl_sim_hal_MKV10Z7.c b/KSDK_1.2.0/platform/hal/src/sim/MKV10Z7/fsl_sim_hal_MKV10Z7.c deleted file mode 100755 index 0d31321..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKV10Z7/fsl_sim_hal_MKV10Z7.c +++ /dev/null @@ -1,946 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - SIM_WR_CLKDIV1(base, (SIM_RD_CLKDIV1(base) & ~(SIM_CLKDIV1_OUTDIV1_MASK | SIM_CLKDIV1_OUTDIV4_MASK)) \ - | (SIM_CLKDIV1_OUTDIV1(outdiv1) | SIM_CLKDIV1_OUTDIV4(outdiv4))); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = 0U; - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetAdcAltClkSrc - * Description : Sets the ADC ALT clock source selection setting. - * This function sets the ADC ALT clock source selection setting. - * - *END**************************************************************************/ -void CLOCK_HAL_SetAdcAltClkSrc(SIM_Type * base, uint32_t instance, clock_adc_alt_src_t adcAltSrcSel) -{ - switch(instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTCLKSRC(base, adcAltSrcSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTCLKSRC(base, adcAltSrcSel); - break; - default: - break; - } - -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetAdcAltClkSrc - * Description : Gets the ADC ALT clock source selection setting. - * This function gets the ADC ALT clock source selection setting. - * - *END**************************************************************************/ -clock_adc_alt_src_t CLOCK_HAL_GetAdcAltClkSrc(SIM_Type * base, uint32_t instance) -{ - assert(instance < ADC_INSTANCE_COUNT); - - if(0 == instance) - { - return (clock_adc_alt_src_t)SIM_BRD_SOPT7_ADC0ALTCLKSRC(base); - } - else - { - return (clock_adc_alt_src_t)SIM_BRD_SOPT7_ADC0ALTCLKSRC(base); - } -} - - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartOpenDrainMode - * Description : Sets the UARTx open drain enable setting. - * This function enables/disables open drain for UARTx. - * - *END**************************************************************************/ -void SIM_HAL_SetUartOpenDrainMode(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < UART_INSTANCE_COUNT); - switch(instance) - { - case 0: - SIM_BWR_SOPT5_UART0ODE(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT5_UART1ODE(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartOpenDrainMode - * Description : Gets the UARTx open drain enable setting. - * This function Gets the UARTx open drain enable setting for UARTx. - * - *END**************************************************************************/ -bool SIM_HAL_GetUartOpenDrainMode(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - assert(instance < UART_INSTANCE_COUNT); - switch(instance) - { - case 0: - retValue = SIM_BRD_SOPT5_UART0ODE(base); - break; - case 1: - retValue = SIM_BRD_SOPT5_UART1ODE(base); - break; - default: - retValue = false; - break; - } - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM0TRG2SRC(base, select); - break; - default: - break; - } - break; - case 1: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM1TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1TRG1SRC(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM1TRG2SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM2TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM2TRG1SRC(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2TRG2SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - case 2: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG2SRC(base); - break; - default: - break; - } - break; - case 1: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM1TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM1TRG1SRC(base); - break; - case 2: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM1TRG2SRC(base); - break; - default: - break; - } - break; - case 2: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM2TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM2TRG1SRC(base); - break; - case 2: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM2TRG2SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1ICH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2ICH0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM2ICH1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1ICH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2ICH0SRC(base); - break; - case 1: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2ICH1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/* Macro for FTMxOCHySRC. */ -#define FTM_CH_OUT_SRC_MASK(instance, channel) \ - (1U << ((((instance)>>1U)*6U) + channel + 16U)) - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChOutSrcMode - * Description : FlexTimer x channel y output source select setting. - * This function will select FlexTimer x channel y output source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_out_src_t select) -{ - assert ((0U==instance) || (2U==instance)); - assert (6U>channel); - - if (kSimFtmChOutSrc0 == select) - { - SIM_CLR_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } - else - { - SIM_SET_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChOutSrcMode - * Description : Get FlexTimer x channel y output source select setting - * This function will get FlexTimer x channel y output source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_out_src_t SIM_HAL_GetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - assert ((0U==instance) || (2U==instance)); - assert (6U>channel); - return (sim_ftm_ch_out_src_t) - (SIM_RD_SOPT8(base) & FTM_CH_OUT_SRC_MASK(instance, channel)); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmSyncCmd - * Description : Set FTMxSYNCBIT - * This function sets FlexTimer x hardware trigger 0 software synchronization. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmSyncCmd(SIM_Type * base, uint32_t instance, bool sync) -{ - assert (instance < FTM_INSTANCE_COUNT); - if (sync) - { - SIM_SET_SOPT8(base, (1U< -/*! - * @addtogroup sim_hal_kv10z7 - * @{ - */ -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief WDOG clock source select */ -typedef enum _clock_wdog_src_t -{ - kClockWdogSrcLpoClk, /*!< LPO */ - kClockWdogSrcAltClk, /*!< Alternative clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_wdog_src_kv10z7_t; -#else -} clock_wdog_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG IRC clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk, /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_kv10z7_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcLpo = 3U, /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_kv10z7_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelBusClk = 2U, /*!< Bus clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCG IRC clock */ - kClockClkoutSelOsc0erClk = 6U, /*!< OSCERCLK0 clock*/ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_kv10z7_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_kv10z7_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /*!< High speed comparator 0 output */ - kSimAdcTrgSelHighSpeedComp1 = 2U, /*!< High speed comparator 1 output */ - kSimAdcTrgSelDma0 = 4U, /*!< DMA channel 0 */ - kSimAdcTrgSelDma1 = 5U, /*!< DMA channel 1 */ - kSimAdcTrgSelDma2 = 6U, /*!< DMA channel 2 */ - kSimAdcTrgSelDma3 = 7U, /*!< DMA channel 3 */ - kSimAdcTrgSelFtm0 = 8U, /*!< FTM0 trigger */ - kSimAdcTrgSelFtm1 = 9U, /*!< FTM1 trigger */ - kSimAdcTrgSelFtm2 = 10U, /*!< FTM2 trigger */ - kSimAdcTrgSelLptimer = 14U /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_kv10z7_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ - kSimUartRxsrcCmp1, /*!< CMP1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_kv10z7_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcFtm1, /*!< UARTx_TX pin modulated with FTM1 channel 0 output */ - kSimUartTxsrcFtm2, /*!< UARTx_TX pin modulated with FTM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_kv10z7_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM FlexTimer x trigger y select */ -typedef enum _sim_ftm_trg_src -{ - kSimFtmTrgSrc0, /*!< FlexTimer x trigger y select 0 */ - kSimFtmTrgSrc1 /*!< FlexTimer x trigger y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_trg_src_kv10z7_t; -#else -} sim_ftm_trg_src_t; -#endif - -/*! @brief SIM FlexTimer external clock select */ -typedef enum _sim_ftm_clk_sel -{ - kSimFtmClkSel0, /*!< FTM CLKIN0 pin. */ - kSimFtmClkSel1, /*!< FTM CLKIN1 pin. */ - kSimFtmClkSel2 /*!< FTM CLKIN2 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_clk_sel_kv10z7_t; -#else -} sim_ftm_clk_sel_t; -#endif - -/*! @brief SIM FlexTimer Fixed Frequency clock source */ -typedef enum _clock_ftm_fixedfreq_src -{ - kClockFtmClkMcgFfClk = 0U, /*!< MCGFFCLK. */ - kClockFtmClkMcgIrClk = 1U, /*!< MCGIRCLK. */ - kClockFtmClkOsc0erClk = 2U, /*!< OSCERCLK. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_ftm_fixedfreq_src_kv10z7_t; -#else -} clock_ftm_fixedfreq_src_t; -#endif - -/*! @brief SIM ADC alt clock source */ -typedef enum _clock_adc_alt_src -{ - kClockAdcAltClkSrcOutdiv5 = 0U, /*!< OUTDIV5 output clock. */ - kClockAdcAltClkSrcMcgIrClk = 1U, /*!< MCGIRCLK. */ - kClockAdcAltClkSrcOsc0erClk = 2U, /*!< OSCERCLK. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_adc_alt_src_kv10z7_t; -#else -} clock_adc_alt_src_t; -#endif - - -/*! @brief SIM FlexTimer x channel y input capture source select */ -typedef enum _sim_ftm_ch_src -{ - kSimFtmChSrc0, /*!< FlexTimer x channel y uses input capture source 0. */ - kSimFtmChSrc1, /*!< FlexTimer x channel y uses input capture source 1. */ - kSimFtmChSrc2, /*!< FlexTimer x channel y uses input capture source 2. */ - kSimFtmChSrc3, /*!< FlexTimer x channel y uses input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_ch_src_kv10z7_t; -#else -} sim_ftm_ch_src_t; -#endif - -/*! @brief SIM FlexTimer x channel y output source select */ -typedef enum _sim_ftm_ch_out_src -{ - kSimFtmChOutSrc0, /*!< FlexTimer x channel y output source 0. */ - kSimFtmChOutSrc1, /*!< FlexTimer x channel y output source 1. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_ch_out_src_kv10z7_t; -#else -} sim_ftm_ch_out_src_t; -#endif - -/*! @brief SIM FlexTimer x Fault y select */ -typedef enum _sim_ftm_flt_sel -{ - kSimFtmFltSel0, /*!< FlexTimer x fault y select 0 */ - kSimFtmFltSel1 /*!< FlexTimer x fault y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_flt_sel_kv10z7_t; -#else -} sim_ftm_flt_sel_t; -#endif - -/*! @brief SIM FlexTimer0/2 output channel Carrier frequency selection */ -typedef enum _sim_ftm_carrier_sel -{ - kSimFtmCarrierSel0, /*!< Carrier frequency selection 0 */ - kSimFtmCarrierSel1 /*!< Carrier frequency selection 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_flt_carrier_sel_kv10z7_t; -#else -} sim_ftm_flt_carrier_sel_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateEwm0 = FSL_SIM_SCGC_BIT(4U, 1U), - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateUart0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateCmp = FSL_SIM_SCGC_BIT(4U, 19U), - - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(6U, 12U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), - kSimClockGatePdb0 = FSL_SIM_SCGC_BIT(6U, 22U), - kSimClockGateFtm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateFtm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateFtm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateAdc1 = FSL_SIM_SCGC_BIT(6U, 28U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(6U, 31U), - - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 8U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_kv10z7_t; -#else -} sim_clock_gate_name_t; -#endif - -/*@}*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Set OUTDIV5EN. - * - * This function sets divide value OUTDIV5EN. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv5ENCmd(SIM_Type * base, bool setting) -{ - SIM_BWR_CLKDIV1_OUTDIV5EN(base, setting); -} - -/*! - * @brief Get OUTDIV5EN. - * - * This function gets divide value OUTDIV5EN. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline bool CLOCK_HAL_GetOutDiv5ENCmd(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV5EN(base); -} - -/*! - * @brief Set OUTDIV5. - * - * This function sets divide value OUTDIV5. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv5(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV5(base, setting); -} - -/*! - * @brief Get OUTDIV5. - * - * This function gets divide value OUTDIV5. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv5(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV5(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -/*! - * @brief Sets the ADC ALT clock source selection setting. - * - * This function sets the ADC ALT clock source selection setting. - * - * @param base Base address for current SIM instance. - * @param instance ADC module instance. - * @param adcAltSrcSel ADC ALT clock source. - */ -void CLOCK_HAL_SetAdcAltClkSrc(SIM_Type * base, uint32_t instance, clock_adc_alt_src_t adcAltSrcSel); - -/*! - * @brief Gets the ADC ALT clock source selection setting. - * - * This function gets the ADC ALT clock source selection setting. - * - * @param base Base address for current SIM instance. - * @param instance ADC module instance. - * @return the ADC ALT clock source selection. - */ -clock_adc_alt_src_t CLOCK_HAL_GetAdcAltClkSrc(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx open drain enable setting. - * - * This function enables/disables open drain for UARTx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable open drain for UARTx - * - true: Open drain is enabled. - * - false: Open drain is disabled. - */ -void SIM_HAL_SetUartOpenDrainMode(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the UARTx open drain enable setting. - * - * This function Gets the UARTx open drain enable setting for UARTx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - */ -bool SIM_HAL_GetUartOpenDrainMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select); - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select); - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the FTM Fixed clock source selection setting. - * - * This function sets the FTM Fixed clock source selection setting. - * - * @param base Base address for current SIM instance. - * @param ftmFixedFreqSel FTM Fixed clock source. - */ -static inline void CLOCK_HAL_SetFtmFixFreqClkSrc(SIM_Type * base, clock_ftm_fixedfreq_src_t ftmFixedFreqSel) -{ - assert(ftmFixedFreqSel < 3); - SIM_BWR_SOPT2_FTMFFCLKSEL(base, ftmFixedFreqSel); -} - -/*! - * @brief Gets the FTM Fixed clock source selection setting. - * - * This function gets the FTM Fixed clock source selection setting. - * - * @param base Base address for current SIM instance. - * @return the FTM Fixed clock source selection. - */ -static inline clock_ftm_fixedfreq_src_t CLOCK_HAL_GetFtmFixFreqClkSrc(SIM_Type * base) -{ - return (clock_ftm_fixedfreq_src_t)SIM_BRD_SOPT2_FTMFFCLKSEL(base); -} - -/*! - * @brief Sets the FlexTimer x hardware trigger y source select setting. - * - * This function selects the source of FTMx hardware trigger y. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @param select FlexTimer x hardware trigger y - * - 0: Pre-trigger A selected for ADCx. - * - 1: Pre-trigger B selected for ADCx. - */ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select); - -/*! - * @brief Gets the FlexTimer x hardware trigger y source select setting. - * - * This function gets the FlexTimer x hardware trigger y source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @return select FlexTimer x hardware trigger y source select setting - */ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger); - -/*! - * @brief Sets the FlexTimer x external clock pin select setting. - * - * This function selects the source of FTMx external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select FTMx external clock pin select - * - 0: FTMx external clock driven by FTM CLKIN0 pin. - * - 1: FTMx external clock driven by FTM CLKIN1 pin. - */ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select); - -/*! - * @brief Gets the FlexTimer x external clock pin select setting. - * - * This function gets the FlexTimer x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select FlexTimer x external clock pin select setting - */ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the FlexTimer x channel y input capture source select setting. - * - * This function selects the FlexTimer x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y input capture source - */ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y input capture source select setting. - * - * This function gets the FlexTimer x channel y input capture - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y input capture source select setting - */ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Sets the Carrier frequency selection for FTM0/2 output channel. - * - * This function Sets the Carrier frequency selection for FTM0/2 output channel. - * - * @param base Base address for current SIM instance. - * @param select Carrier frequency source select. - * - 0 : FTM1_CH1 output provides the carrier signal; - * - 1 : LPTMR0 pre-scaler output provides the carrier signal; - */ -static inline void SIM_HAL_SetFtmCarrierFreqMode(SIM_Type * base, - sim_ftm_flt_carrier_sel_t select) -{ - SIM_BWR_SOPT8_CARRIER_SELECT(base, select); -} - -/*! - * @brief Gets the Carrier frequency selection for FTM0/2 output channel. - * - * This function gets Carrier frequency selection setting for FTM0/2 output channel. - * - * @param base Base address for current SIM instance. - * @return Carrier frequency selection; - */ -static inline sim_ftm_flt_carrier_sel_t SIM_HAL_GetFtmCarrierFreqMode(SIM_Type * base) -{ - return (sim_ftm_flt_carrier_sel_t)SIM_BRD_SOPT8_CARRIER_SELECT(base); -} - -/*! - * @brief Sets the FlexTimer x channel y output source select setting. - * - * This function selects the FlexTimer x channel y output source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y output source - */ -void SIM_HAL_SetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_out_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y output source select setting. - * - * This function gets the FlexTimer x channel y output - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y output source select setting - */ -sim_ftm_ch_out_src_t SIM_HAL_GetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Set FlexTimer x hardware trigger 0 software synchronization. - * - * This function sets FlexTimer x hardware trigger 0 software synchronization. - * FTMxSYNCBIT. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param sync Synchronize or not. - */ -void SIM_HAL_SetFtmSyncCmd(SIM_Type * base, uint32_t instance, bool sync); - -/*! - * @brief Get FlexTimer x hardware trigger 0 software synchronization setting. - * - * This function gets FlexTimer x hardware trigger 0 software synchronization. - * FTMxSYNCBIT. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - */ -static inline bool SIM_HAL_GetFtmSyncCmd(SIM_Type * base, uint32_t instance) -{ - assert (instance < FTM_INSTANCE_COUNT); - return (bool)(SIM_RD_SOPT8(base) & (1U< -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM2CH1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - case 1: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - - - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - SIM_BWR_SOPT4_FTM0FLT0(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0FLT1(base, select); - break; - default: - break; - } - break; - case 1: - SIM_BWR_SOPT4_FTM1FLT0(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2FLT0(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type * base, - uint32_t instance, - uint8_t fault) -{ - sim_ftm_flt_sel_t retValue = (sim_ftm_flt_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT0(base); - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT1(base); - break; - default: - break; - } - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM1FLT0(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM2FLT0(base); - break; - default: - break; - } - - return retValue; -} - -/* Macro for FTMxOCHySRC. */ -#define FTM_CH_OUT_SRC_MASK(instance, channel) \ - (1U << (((instance)>>1U) + channel + 16U)) - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChOutSrcMode - * Description : FlexTimer x channel y output source select setting. - * This function will select FlexTimer x channel y output source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_out_src_t select) -{ - assert (0U==instance); - assert (6U>channel); - - if (kSimFtmChOutSrc0 == select) - { - SIM_CLR_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } - else - { - SIM_SET_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChOutSrcMode - * Description : Get FlexTimer x channel y output source select setting - * This function will get FlexTimer x channel y output source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_out_src_t SIM_HAL_GetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - assert (0U==instance); - assert (6U>channel); - return (sim_ftm_ch_out_src_t) - (SIM_RD_SOPT8(base) & FTM_CH_OUT_SRC_MASK(instance, channel)); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmSyncCmd - * Description : Set FTMxSYNCBIT - * This function sets FlexTimer x hardware trigger 0 software synchronization. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmSyncCmd(SIM_Type * base, uint32_t instance, bool sync) -{ - assert (instance < FTM_INSTANCE_COUNT); - if (sync) - { - SIM_SET_SOPT8(base, (1U< -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - /* Only supprt FTM0 trigger. */ - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - /* Only supprt FTM0 trigger. */ - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM2CH1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - case 1: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/* Macro for FTMxOCHySRC. Only support FTM0. */ -#define FTM_CH_OUT_SRC_MASK(instance, channel) (1U << (channel + 16U)) - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChOutSrcMode - * Description : FlexTimer x channel y output source select setting. - * This function will select FlexTimer x channel y output source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_out_src_t select) -{ - assert ((0U==instance)); - assert (8U>channel); - - if (kSimFtmChOutSrc0 == select) - { - SIM_CLR_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } - else - { - SIM_SET_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChOutSrcMode - * Description : Get FlexTimer x channel y output source select setting - * This function will get FlexTimer x channel y output source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_out_src_t SIM_HAL_GetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - assert (0U==instance); - assert (8U>channel); - return (sim_ftm_ch_out_src_t) - (SIM_RD_SOPT8(base) & FTM_CH_OUT_SRC_MASK(instance, channel)); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmSyncCmd - * Description : Set FTMxSYNCBIT - * This function sets FlexTimer x hardware trigger 0 software synchronization. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmSyncCmd(SIM_Type * base, uint32_t instance, bool sync) -{ - assert (instance < FTM_INSTANCE_COUNT); - if (sync) - { - SIM_SET_SOPT8(base, (1U< -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - /* Only supprt FTM0 trigger. */ - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - /* Only supprt FTM0 trigger. */ - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM2CH1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - case 1: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/* Macro for FTMxOCHySRC. Only support FTM0. */ -#define FTM_CH_OUT_SRC_MASK(instance, channel) (1U << (channel + 16U)) - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChOutSrcMode - * Description : FlexTimer x channel y output source select setting. - * This function will select FlexTimer x channel y output source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_out_src_t select) -{ - assert ((0U==instance)); - assert (8U>channel); - - if (kSimFtmChOutSrc0 == select) - { - SIM_CLR_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } - else - { - SIM_SET_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChOutSrcMode - * Description : Get FlexTimer x channel y output source select setting - * This function will get FlexTimer x channel y output source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_out_src_t SIM_HAL_GetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - assert (0U==instance); - assert (8U>channel); - return (sim_ftm_ch_out_src_t) - (SIM_RD_SOPT8(base) & FTM_CH_OUT_SRC_MASK(instance, channel)); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmSyncCmd - * Description : Set FTMxSYNCBIT - * This function sets FlexTimer x hardware trigger 0 software synchronization. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmSyncCmd(SIM_Type * base, uint32_t instance, bool sync) -{ - assert (instance < FTM_INSTANCE_COUNT); - if (sync) - { - SIM_SET_SOPT8(base, (1U< -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV3(outdiv3); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv3 = SIM_BRD_CLKDIV1_OUTDIV3(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable settingg - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - case 1: - retValue = SIM_BRD_SOPT7_ADC1ALTTRGEN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - case 1: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC1PRETRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - case 1: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC1TRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC1PRETRGSEL(base, preTrigSel); - break; - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - case 1: - SIM_BWR_SOPT7_ADC1TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - case 3: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM3TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM3TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - case 3: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM3TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM3TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - case 3: - SIM_BWR_SOPT4_FTM3CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type * base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - case 3: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM3CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM2CH1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - case 1: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/* Macro for FTMxOCHySRC. */ -#define FTM_CH_OUT_SRC_MASK(instance, channel) \ - (1U << ((((instance)>>1U)*8U) + channel + 16U)) - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChOutSrcMode - * Description : FlexTimer x channel y output source select setting. - * This function will select FlexTimer x channel y output source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_out_src_t select) -{ - assert ((0U==instance) || (3U==instance)); - assert (8U>channel); - - if (kSimFtmChOutSrc0 == select) - { - SIM_CLR_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } - else - { - SIM_SET_SOPT8(base, FTM_CH_OUT_SRC_MASK(instance, channel)); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChOutSrcMode - * Description : Get FlexTimer x channel y output source select setting - * This function will get FlexTimer x channel y output source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_out_src_t SIM_HAL_GetFtmChOutSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - assert ((0U==instance) || (3U==instance)); - assert (8U>channel); - return (sim_ftm_ch_out_src_t) - (SIM_RD_SOPT8(base) & FTM_CH_OUT_SRC_MASK(instance, channel)); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmSyncCmd - * Description : Set FTMxSYNCBIT - * This function sets FlexTimer x hardware trigger 0 software synchronization. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmSyncCmd(SIM_Type * base, uint32_t instance, bool sync) -{ - assert (instance < FTM_INSTANCE_COUNT); - if (sync) - { - SIM_SET_SOPT8(base, (1U< -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type* base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type* base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableDmaClock - * Description : Enable the clock for DMA module - * This function enables the clock for DMA moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableDmaClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC7_DMA(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableDmaClock - * Description : Disable the clock for DMA module - * This function disables the clock for DMA moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableDmaClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC7_DMA(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetDmaGateCmd - * Description : Get the the clock gate state for DMA module - * This function will get the clock gate state for DMA moudle - * - *END**************************************************************************/ -bool SIM_HAL_GetDmaGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC7_DMA(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableDmamuxClock - * Description : Enable the clock for DMAMUX module - * This function enables the clock for DMAMUX moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableDmamuxClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_DMAMUX(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableDmamuxClock - * Description : Disable the clock for DMAMUX module - * This function disables the clock for DMAMUX moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableDmamuxClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_DMAMUX(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetDmamuxGateCmd - * Description : Get the the clock gate state for DMAMUX module - * This function will get the clock gate state for DMAMUX moudle - * - *END**************************************************************************/ -bool SIM_HAL_GetDmamuxGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC6_DMAMUX(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void SIM_HAL_EnablePortClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC5_PORTA(base, 1); - break; - case 1: - SIM_BWR_SCGC5_PORTB(base, 1); - break; - case 2: - SIM_BWR_SCGC5_PORTC(base, 1); - break; - case 3: - SIM_BWR_SCGC5_PORTD(base, 1); - break; - case 4: - SIM_BWR_SCGC5_PORTE(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void SIM_HAL_DisablePortClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC5_PORTA(base, 0); - break; - case 1: - SIM_BWR_SCGC5_PORTB(base, 0); - break; - case 2: - SIM_BWR_SCGC5_PORTC(base, 0); - break; - case 3: - SIM_BWR_SCGC5_PORTD(base, 0); - break; - case 4: - SIM_BWR_SCGC5_PORTE(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetPortGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_SCGC5_PORTA(base); - break; - case 1: - retValue = SIM_BRD_SCGC5_PORTB(base); - break; - case 2: - retValue = SIM_BRD_SCGC5_PORTC(base); - break; - case 3: - retValue = SIM_BRD_SCGC5_PORTD(base); - break; - case 4: - retValue = SIM_BRD_SCGC5_PORTE(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableEwmClock - * Description : Enable the clock for EWM module - * This function enables the clock for EWM moudle. - * - *END**************************************************************************/ -void SIM_HAL_EnableEwmClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC4_EWM(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableEwmClock - * Description : Disable the clock for EWM modul - * This function disables the clock for EWM moudle. - * - *END**************************************************************************/ -void SIM_HAL_DisableEwmClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC4_EWM(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetEwmGateCmd - * Description : Get the the clock gate state for EWM module - * This function will get the clock gate state for EWM moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetEwmGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC4_EWM(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableFtfClock - * Description : Enable the clock for FTF module - * This function enables the clock for FTF moudle. - * - *END**************************************************************************/ -void SIM_HAL_EnableFtfClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_FTF(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableFtfClock - * Description : Disable the clock for FTF module - * This function disables the clock for FTF moudle. - * - *END**************************************************************************/ -void SIM_HAL_DisableFtfClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_FTF(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtfGateCmd - * Description : Get the the clock gate state for FTF module - * This function will get the clock gate state for FTF moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetFtfGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC6_FTF(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableCrcClock - * Description : Enable the clock for CRC module - * This function enables the clock for CRC moudle. - * - *END**************************************************************************/ -void SIM_HAL_EnableCrcClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_CRC(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableCrcClock - * Description : Disable the clock for CRC module - * This function disables the clock for CRC moudle. - * - *END**************************************************************************/ -void SIM_HAL_DisableCrcClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_CRC(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetCrcGateCmd - * Description : Get the the clock gate state for CRC module - * This function will get the clock gate state for CRC moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetCrcGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC6_CRC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableAdcClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC5_ADC(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableAdcClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC5_ADC(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - retValue = SIM_BRD_SCGC5_ADC(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableCmpClock - * Description : Enable the clock for CMP module - * This function enables the clock for CMP moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableCmpClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC4_CMP(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableCmpClock - * Description : Disable the clock for CMP module - * This function disables the clock for CMP moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableCmpClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC4_CMP(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetCmpGateCmd - * Description : Get the the clock gate state for CMP module - * This function will get the clock gate state for CMP moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetCmpGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC4_CMP(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableDacClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_DAC0(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableDacClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_DAC0(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetDacGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - retValue = SIM_BRD_SCGC6_DAC0(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnablePdbClock - * Description : Enable the clock for PDB module - * This function enables the clock for PDB moudle - * - *END**************************************************************************/ -void SIM_HAL_EnablePdbClock(SIM_Type* base, uint32_t instance) -{ - switch(instance) - { - case 0: - SIM_BWR_SCGC6_PDB0(base, 1); - break; - case 1: - SIM_BWR_SCGC6_PDB1(base, 1); - break; - default: break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisablePdbClock - * Description : Disable the clock for PDB module - * This function disables the clock for PDB moudle - * - *END**************************************************************************/ -void SIM_HAL_DisablePdbClock(SIM_Type* base, uint32_t instance) -{ - switch(instance) - { - case 0: - SIM_BWR_SCGC6_PDB0(base, 0); - break; - case 1: - SIM_BWR_SCGC6_PDB1(base, 0); - break; - default: break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetPdbGateCmd - * Description : Get the the clock gate state for PDB module - * This function will get the clock gate state for PDB moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetPdbGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch(instance) - { - case 0: - retValue = SIM_BRD_SCGC6_PDB0(base); - break; - case 1: - retValue = SIM_BRD_SCGC6_PDB1(base); - break; - default: break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableFtmClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC6_FTM0(base, 1); - break; - case 1: - SIM_BWR_SCGC6_FTM1(base, 1); - break; - case 3: - SIM_BWR_SCGC6_FTM3(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableFtmClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC6_FTM0(base, 0); - break; - case 1: - SIM_BWR_SCGC6_FTM1(base, 0); - break; - case 3: - SIM_BWR_SCGC6_FTM3(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetFtmGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_SCGC6_FTM0(base); - break; - case 1: - retValue = SIM_BRD_SCGC6_FTM1(base); - break; - case 2: - retValue = false; - break; - case 3: - retValue = SIM_BRD_SCGC6_FTM3(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcxMuxSelChannely - * Description : ADC x (0-A, 1-B)channel y (6,7) Mux. - * Refer to RM for specific channel settings - * Selects ADCx MUX0's channel to ADCx channel y. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcxMuxSelChannely(SIM_Type* base, uint32_t instance, - uint8_t channel, uint8_t select) -{ - assert (instance<2); - assert (channel<8); - assert (channel>5); - switch(instance) - { - case 0: - switch(channel) - { - case 6: - SIM_BWR_ADCOPT_ADCACH6SEL(base, select); - break; - case 7: - SIM_BWR_ADCOPT_ADCACH7SEL(base, select); - break; - default: - break; - } - break; - case 1: - switch(channel) - { - case 6: - SIM_BWR_ADCOPT_ADCBCH6SEL(base, select); - break; - case 7: - SIM_BWR_ADCOPT_ADCBCH7SEL(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChOutSrcMode - * Description : Get FlexTimer x channel y output source select setting - * This function will get FlexTimer x channel y output source select - * setting. - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetAdcxMuxSelChannely(SIM_Type* base, uint32_t instance, uint8_t channel) -{ - assert (instance<2); - assert (channel<8); - assert (channel>5); - uint8_t retValue = (uint8_t) false; - switch(instance) - { - case 0: - switch(channel) - { - case 6: - retValue = (uint8_t)SIM_BRD_ADCOPT_ADCACH6SEL(base); - break; - case 7: - retValue = (uint8_t)SIM_BRD_ADCOPT_ADCACH7SEL(base); - break; - default: - retValue = (uint8_t) false; - break; - } - break; - case 3: - switch(channel) - { - case 6: - retValue = (uint8_t)SIM_BRD_ADCOPT_ADCBCH6SEL(base); - break; - case 7: - retValue = (uint8_t)SIM_BRD_ADCOPT_ADCBCH7SEL(base); - break; - default: - retValue = (uint8_t) false; - break; - } - break; - default: - retValue = (uint8_t) false; - break; - } - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetNanoedgeRegulator12SupStdbyControl - * Description : Nanoedge Regulator 1.2 V Supply Standby Control - * This function controls the standby mode of the 1.2 V supply from the nanoedge voltage regulator. - * 00 Nanoedge regulator 1.2 V supply placed in normal mode - * 01 Nanoedge regulator 1.2 V supply placed in standby mode. - * 10 Nanoedge regulator 1.2 V supply placed in normal mode and SR12STDBY is write protected until - * chip reset. - * 11 Nanoedge regulator 1.2 V supply placed in standby mode and SR12STDBY is write protected until - * chip reset. - * - *END**************************************************************************/ -void SIM_HAL_SetNanoedgeRegulator12SupStdbyControl(SIM_Type* base, uint8_t select) -{ - assert (select < 4); - SIM_BWR_PWRC_SR12STDBY(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetNanoedgeRegulator12SupStdbyControl - * Description : Get Nanoedge Regulator 1.2 V Supply Standby Control - * This function will get the standby mode of the 1.2 V supply from the nanoedge voltage regulator - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetNanoedgeRegulator12SupStdbyControl(SIM_Type* base) -{ - return (uint8_t)SIM_BRD_PWRC_SR12STDBY(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetNanoedgeRegulator27SupStdbyControl - * Description : Nanoedge Regulator 2.7 V Supply Standby Control - * This function controls the standby mode of the 2.7 V supply from the nanoedge voltage regulator. - * 00 Nanoedge regulator 2.7 V supply placed in normal mode - * 01 Nanoedge regulator 2.7 V supply placed in standby mode. - * 10 Nanoedge regulator 2.7 V supply placed in normal mode and SR27STDBY is write protected until - * chip reset. - * 11 Nanoedge regulator 2.7 V supply placed in standby mode and SR27STDBY is write protected until - * chip reset. - * - *END**************************************************************************/ -void SIM_HAL_SetNanoedgeRegulator27SupStdbyControl(SIM_Type* base, uint8_t select) -{ - assert (select < 4); - SIM_BWR_PWRC_SR12STDBY(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetNanoedgeRegulator27SupStdbyControl - * Description : Get Nanoedge Regulator 2.7 V Supply Standby Control - * This function will get the standby mode of the 2.7 V supply from the nanoedge voltage regulator - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetNanoedgeRegulator27SupStdbyControl(SIM_Type* base) -{ - return (uint8_t)SIM_BRD_PWRC_SR12STDBY(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetNanoedgeReg27n12SupPwrdwnControl - * Description : Nanoedge Regulator 2.7V and 1.2V Supply Powerdown Control - * This function controls the powerdown mode of the 2.7V and 1.2V supply from the nanoedge voltage regulator - * 00 Nanoedge regulator placed in normal mode. - * 01 Nanoedge regulator placed in powerdown mode. - * 10 Nanoedge regulator placed in normal mode and SRPDN is write protected until chip reset. - * 11 Nanoedge regulator placed in powerdown mode and SRPDN is write protected until chip reset. - * - *END**************************************************************************/ -void SIM_HAL_SetNanoedgeReg27n12SupPwrdwnControl(SIM_Type* base, uint8_t select) -{ - assert (select < 4); - SIM_BWR_PWRC_SRPDN(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetNanoedgeReg27n12SupPwrdwnControl - * Description : Get Nanoedge Regulator 2.7 V Supply Standby Control - * This function will get the standby mode of the 2.7 V supply from the nanoedge voltage regulator - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetNanoedgeReg27n12SupPwrdwnControl(SIM_Type* base) -{ - return (uint8_t)SIM_BRD_PWRC_SRPDN(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetWdogClkSrc - * Description : WDOG Clock Select - * This function selects the clock source of the WDOG2008 watchdog. - * 0 Internal 1 kHz clock is source to WDOG2008 - * 1 MCGIRCLK is source to WDOG2008 - * - *END**************************************************************************/ -void SIM_HAL_SetWdogClkSrc(SIM_Type* base, bool select) -{ - SIM_BWR_WDOGC_WDOGCLKS(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetWdogClkSrc - * Description : Get WDOG Clock setting - * This function will get the clock source of the WDOG2008 watchdog - * - *END**************************************************************************/ -bool SIM_HAL_GetWdogClkSrc(SIM_Type* base) -{ - return (bool)SIM_BRD_WDOGC_WDOGCLKS(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarAPittrigX - * Description : Synchronize XBARA's Input PIT Trigger X with fast clock - * This function controls the synchronizer between PIT trigger X and XBARA's input. - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarAPittrigX(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG0(base, 1); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG1(base, 1); - break; - case 2: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG2(base, 1); - break; - case 3: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG3(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarAPittrigX - * Description : Disable the synchronizer between PIT trigger X and XBARA's input - * This function Disables the synchronizer between PIT trigger X and XBARA's input - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarAPittrigX(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG0(base, 0); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG1(base, 0); - break; - case 2: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG2(base, 0); - break; - case 3: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG3(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarAPittrigXcmd - * Description : Get the synchronizer cmd between PIT trigger X and XBARA's input - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarAPittrigXcmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_MISCTRL2_SYNCXBARAPITTRIG0(base); - break; - case 1: - retValue = SIM_BRD_MISCTRL2_SYNCXBARAPITTRIG1(base); - break; - case 2: - retValue = SIM_BRD_MISCTRL2_SYNCXBARAPITTRIG2(base); - break; - case 3: - retValue = SIM_BRD_MISCTRL2_SYNCXBARAPITTRIG3(base); - break; - default: - retValue = false; - break; - } - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarBPittrigX - * Description : Synchronize XBARB's Input PIT Trigger X with fast clock - * This function controls the synchronizer between PIT trigger X and XBARB's input. - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarBPittrigX(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCXBARBPITTRIG0(base, 1); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCXBARBPITTRIG1(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarBPittrigX - * Description : Disable the synchronizer between PIT trigger X and XBARB's input - * This function Disables the synchronizer between PIT trigger X and XBARB's input - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarBPittrigX(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCXBARBPITTRIG0(base, 0); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCXBARBPITTRIG1(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarBPittrigXcmd - * Description : Get the synchronizer cmd between PIT trigger X and XBARB's input - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarBPittrigXcmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_MISCTRL2_SYNCXBARBPITTRIG0(base); - break; - case 1: - retValue = SIM_BRD_MISCTRL2_SYNCXBARBPITTRIG1(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarDac - * Description : Synchronize XBARA's output for DAC Hardware Trigger with flash/slow clock - * This function controls the synchronizer between XBARA's output and DAC hardware trigger. - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarDac(SIM_Type* base) -{ - SIM_BWR_MISCTRL2_SYNCDACHWTRIG(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarDac - * Description : Disable the synchronizer between XBARA's output and DAC hardware trigger - * This function Disables the synchronizer between XBARA's output and DAC hardware trigger - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarDac(SIM_Type* base) -{ - SIM_BWR_MISCTRL2_SYNCDACHWTRIG(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarDaccmd - * Description : Get the synchronizer cmd between XBARA's output and DAC hardware trigger - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarDaccmd(SIM_Type* base) -{ - return (bool)SIM_BRD_MISCTRL2_SYNCDACHWTRIG(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarEwmin - * Description : Enable the synchronizer between XBARA's output and EWM's ewm_in - * This function enables the synchronizer between XBARA's output and EWM's ewm_in - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarEwmin(SIM_Type* base) -{ - SIM_BWR_MISCTRL2_SYNCEWMIN(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarEwmin - * Description : Disable the synchronizer between XBARA's output and EWM's ewm_in - * This function Disables the synchronizer between XBARA's output and EWM's ewm_in - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarEwmin(SIM_Type* base) -{ - SIM_BWR_MISCTRL2_SYNCEWMIN(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarEwmincmd - * Description : Get the synchronizer cmd between XBARA's output and EWM's ewm_in - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarEwmincmd(SIM_Type* base) -{ - return (bool)SIM_BRD_MISCTRL2_SYNCEWMIN(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarCmpX - * Description : Enable the the synchronizer between XBARA's output and CMP3's sample/window input - * This function enables the the synchronizer between XBARA's output and CMP3's sample/window input - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarCmpX(SIM_Type* base, uint32_t instance) -{ - assert (instance < CMP_INSTANCE_COUNT); - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCCMP0SAMPLEWIN(base, 1); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCCMP1SAMPLEWIN(base, 1); - break; - case 2: - SIM_BWR_MISCTRL2_SYNCCMP2SAMPLEWIN(base, 1); - break; - case 3: - SIM_BWR_MISCTRL2_SYNCCMP3SAMPLEWIN(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarCmpX - * Description : Disable the synchronizer between XBARA's output and CMP3's sample/window input - * This function Disables the synchronizer between XBARA's output and CMP3's sample/window input - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarCmpX(SIM_Type* base, uint32_t instance) -{ - assert (instance < CMP_INSTANCE_COUNT); - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCCMP0SAMPLEWIN(base, 0); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCCMP1SAMPLEWIN(base, 0); - break; - case 2: - SIM_BWR_MISCTRL2_SYNCCMP2SAMPLEWIN(base, 0); - break; - case 3: - SIM_BWR_MISCTRL2_SYNCCMP3SAMPLEWIN(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarCmpXcmd - * Description : Get the synchronizer cmd between XBARA's output and CMP3's sample/window input - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarCmpXcmd(SIM_Type* base, uint32_t instance) -{ - assert (instance < CMP_INSTANCE_COUNT); - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_MISCTRL2_SYNCCMP0SAMPLEWIN(base); - break; - case 1: - retValue = SIM_BRD_MISCTRL2_SYNCCMP1SAMPLEWIN(base); - break; - case 2: - retValue = SIM_BRD_MISCTRL2_SYNCCMP2SAMPLEWIN(base); - break; - case 3: - retValue = SIM_BRD_MISCTRL2_SYNCCMP3SAMPLEWIN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetCmpWinxSrc - * Description : Set CMP Sample/Window Input X Source - * This function controls the sample/window source of CMP module - * - *END**************************************************************************/ -void SIM_HAL_SetCmpWinxSrc(SIM_Type* base, uint32_t instance, - sim_cmp_win_in_src select) -{ - assert (instance < CMP_INSTANCE_COUNT); - switch (instance) - { - case 0: - SIM_BWR_MISCTRL_CMPWIN0SRC(base, select); - break; - case 1: - SIM_BWR_MISCTRL_CMPWIN1SRC(base, select); - break; - case 2: - SIM_BWR_MISCTRL_CMPWIN2SRC(base, select); - break; - case 3: - SIM_BWR_MISCTRL_CMPWIN3SRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetCmpWinxSrc - * Description : Get CMP Sample/Window Input X Source - * This function will get the sample/window source of CMP module - * - *END**************************************************************************/ -sim_cmp_win_in_src SIM_HAL_GetCmpWinxSrc(SIM_Type* base, uint32_t instance) -{ - assert (instance < CMP_INSTANCE_COUNT); - sim_cmp_win_in_src retValue = (sim_cmp_win_in_src)0; - switch (instance) - { - case 0: - retValue = (sim_cmp_win_in_src)SIM_BRD_MISCTRL_CMPWIN0SRC(base); - break; - case 1: - retValue = (sim_cmp_win_in_src)SIM_BRD_MISCTRL_CMPWIN1SRC(base); - break; - case 2: - retValue = (sim_cmp_win_in_src)SIM_BRD_MISCTRL_CMPWIN2SRC(base); - break; - case 3: - retValue = (sim_cmp_win_in_src)SIM_BRD_MISCTRL_CMPWIN3SRC(base); - break; - default: - break; - } - - return retValue; -} - - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetEwmInSrc - * Description : Set EWM_IN source setting - * This function controls the ewm_in source of EWM module - * - *END**************************************************************************/ -void SIM_HAL_SetEwmInSrc(SIM_Type* base, sim_ewm_in_src select) -{ - SIM_BWR_MISCTRL_EWMINSRC(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetEwmInSrc - * Description : Get EWM_IN source setting - * This function will get the ewm_in source of EWM module - * - *END**************************************************************************/ -sim_ewm_in_src SIM_HAL_GetEwmInSrc(SIM_Type* base) -{ - return (sim_ewm_in_src)SIM_BRD_MISCTRL_EWMINSRC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetDacHwTrigSrc - * Description : Set DAC x Hardware trigger source setting - * This function will select the DAC0 Hardware Trigger Input Source - * - *END**************************************************************************/ -void SIM_HAL_SetDacHwTrigSrc(SIM_Type* base,sim_dac_hw_trg_sel select) -{ - SIM_BWR_MISCTRL_DACTRIGSRC(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetDacHwTrigSrc - * Description : Get DAC x Hardware trigger source setting - * This function will get the DAC0 Hardware Trigger Input Source - * - *END**************************************************************************/ -sim_dac_hw_trg_sel SIM_HAL_GetDacHwTrigSrc(SIM_Type* base, uint32_t instance) -{ - return (sim_dac_hw_trg_sel)SIM_BRD_MISCTRL_DACTRIGSRC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT9_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT9_FTM1CLKSEL(base, select); - break; - case 3: - SIM_BWR_SOPT9_FTM3CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT9_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT9_FTM1CLKSEL(base); - break; - case 3: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT9_FTM3CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT9_FTM1ICH0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT9_FTM1ICH1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)false; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT9_FTM1ICH0SRC(base); - break; - case 1: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT9_FTM1ICH1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChOutSrcMode - * Description : FlexTimer x channel y output source select setting. - * This function will select FlexTimer x channel y output source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChOutSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_out_src_t select) -{ - switch(instance) - { - case 0: - switch(channel) - { - case 0: - SIM_BWR_SOPT8_FTM0OCH0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT8_FTM0OCH1SRC(base, select); - break; - case 2: - SIM_BWR_SOPT8_FTM0OCH2SRC(base, select); - break; - case 3: - SIM_BWR_SOPT8_FTM0OCH3SRC(base, select); - break; - case 4: - SIM_BWR_SOPT8_FTM0OCH4SRC(base, select); - break; - case 5: - SIM_BWR_SOPT8_FTM0OCH5SRC(base, select); - break; - case 6: - SIM_BWR_SOPT8_FTM0OCH6SRC(base, select); - break; - case 7: - SIM_BWR_SOPT8_FTM0OCH7SRC(base, select); - break; - default: - break; - } - break; - case 3: - switch(channel) - { - case 0: - SIM_BWR_SOPT8_FTM3OCH0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT8_FTM3OCH1SRC(base, select); - break; - case 2: - SIM_BWR_SOPT8_FTM3OCH2SRC(base, select); - break; - case 3: - SIM_BWR_SOPT8_FTM3OCH3SRC(base, select); - break; - case 4: - SIM_BWR_SOPT8_FTM3OCH4SRC(base, select); - break; - case 5: - SIM_BWR_SOPT8_FTM3OCH5SRC(base, select); - break; - case 6: - SIM_BWR_SOPT8_FTM3OCH6SRC(base, select); - break; - case 7: - SIM_BWR_SOPT8_FTM3OCH7SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChOutSrcMode - * Description : Get FlexTimer x channel y output source select setting - * This function will get FlexTimer x channel y output source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_out_src_t SIM_HAL_GetFtmChOutSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_out_src_t retValue = (sim_ftm_ch_out_src_t) false; - switch(instance) - { - case 0: - switch(channel) - { - case 0: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH0SRC(base); - break; - case 1: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH1SRC(base); - break; - case 2: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH2SRC(base); - break; - case 3: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH3SRC(base); - break; - case 4: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH4SRC(base); - break; - case 5: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH5SRC(base); - break; - case 6: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH6SRC(base); - break; - case 7: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH7SRC(base); - break; - default: - retValue = (sim_ftm_ch_out_src_t) false; - break; - } - break; - case 3: - switch(channel) - { - case 0: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH0SRC(base); - break; - case 1: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH1SRC(base); - break; - case 2: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH2SRC(base); - break; - case 3: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH3SRC(base); - break; - case 4: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH4SRC(base); - break; - case 5: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH5SRC(base); - break; - case 6: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH6SRC(base); - break; - case 7: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH7SRC(base); - break; - default: - retValue = (sim_ftm_ch_out_src_t) false; - break; - } - break; - default: - retValue = (sim_ftm_ch_out_src_t) false; - break; - } - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmCarrierFreqCmd - * Description : Set FTMxCFSELBIT - * This function sets FlexTimer x carrier frequency selection software configuration setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmCarrierFreqCmd(SIM_Type* base, uint32_t instance, bool ftmcarrierfreqsrc) -{ - assert (instance < FTM_INSTANCE_COUNT); - switch(instance) - { - case 0: - SIM_BWR_SOPT8_FTM0CFSEL(base,ftmcarrierfreqsrc); - break; - case 3: - SIM_BWR_SOPT8_FTM3CFSEL(base,ftmcarrierfreqsrc); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmCarrierFreqCmd - * Description : Get FlexTimer x carrier frequency selection software configuration setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetFtmCarrierFreqCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - assert (instance < FTM_INSTANCE_COUNT); - switch(instance) - { - case 0: - retValue = SIM_BRD_SOPT8_FTM0CFSEL(base); - break; - case 3: - retValue = SIM_BRD_SOPT8_FTM3CFSEL(base); - break; - default: - retValue = false; - break; - } - return retValue; -} -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmSyncCmd - * Description : Set FTMxSYNCBIT - * This function sets FlexTimer x hardware trigger 0 software synchronization. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmSyncCmd(SIM_Type* base, uint32_t instance, bool sync) -{ - assert (instance < FTM_INSTANCE_COUNT); - if (sync) - { - SIM_SET_SOPT8(base, (1U< -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type* base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type* base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableDmaClock - * Description : Enable the clock for DMA module - * This function enables the clock for DMA moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableDmaClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC7_DMA(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableDmaClock - * Description : Disable the clock for DMA module - * This function disables the clock for DMA moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableDmaClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC7_DMA(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetDmaGateCmd - * Description : Get the the clock gate state for DMA module - * This function will get the clock gate state for DMA moudle - * - *END**************************************************************************/ -bool SIM_HAL_GetDmaGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC7_DMA(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableDmamuxClock - * Description : Enable the clock for DMAMUX module - * This function enables the clock for DMAMUX moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableDmamuxClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_DMAMUX(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableDmamuxClock - * Description : Disable the clock for DMAMUX module - * This function disables the clock for DMAMUX moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableDmamuxClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_DMAMUX(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetDmamuxGateCmd - * Description : Get the the clock gate state for DMAMUX module - * This function will get the clock gate state for DMAMUX moudle - * - *END**************************************************************************/ -bool SIM_HAL_GetDmamuxGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC6_DMAMUX(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void SIM_HAL_EnablePortClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC5_PORTA(base, 1); - break; - case 1: - SIM_BWR_SCGC5_PORTB(base, 1); - break; - case 2: - SIM_BWR_SCGC5_PORTC(base, 1); - break; - case 3: - SIM_BWR_SCGC5_PORTD(base, 1); - break; - case 4: - SIM_BWR_SCGC5_PORTE(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void SIM_HAL_DisablePortClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC5_PORTA(base, 0); - break; - case 1: - SIM_BWR_SCGC5_PORTB(base, 0); - break; - case 2: - SIM_BWR_SCGC5_PORTC(base, 0); - break; - case 3: - SIM_BWR_SCGC5_PORTD(base, 0); - break; - case 4: - SIM_BWR_SCGC5_PORTE(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetPortGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_SCGC5_PORTA(base); - break; - case 1: - retValue = SIM_BRD_SCGC5_PORTB(base); - break; - case 2: - retValue = SIM_BRD_SCGC5_PORTC(base); - break; - case 3: - retValue = SIM_BRD_SCGC5_PORTD(base); - break; - case 4: - retValue = SIM_BRD_SCGC5_PORTE(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableEwmClock - * Description : Enable the clock for EWM module - * This function enables the clock for EWM moudle. - * - *END**************************************************************************/ -void SIM_HAL_EnableEwmClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC4_EWM(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableEwmClock - * Description : Disable the clock for EWM modul - * This function disables the clock for EWM moudle. - * - *END**************************************************************************/ -void SIM_HAL_DisableEwmClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC4_EWM(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetEwmGateCmd - * Description : Get the the clock gate state for EWM module - * This function will get the clock gate state for EWM moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetEwmGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC4_EWM(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableFtfClock - * Description : Enable the clock for FTF module - * This function enables the clock for FTF moudle. - * - *END**************************************************************************/ -void SIM_HAL_EnableFtfClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_FTF(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableFtfClock - * Description : Disable the clock for FTF module - * This function disables the clock for FTF moudle. - * - *END**************************************************************************/ -void SIM_HAL_DisableFtfClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_FTF(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtfGateCmd - * Description : Get the the clock gate state for FTF module - * This function will get the clock gate state for FTF moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetFtfGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC6_FTF(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableCrcClock - * Description : Enable the clock for CRC module - * This function enables the clock for CRC moudle. - * - *END**************************************************************************/ -void SIM_HAL_EnableCrcClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_CRC(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableCrcClock - * Description : Disable the clock for CRC module - * This function disables the clock for CRC moudle. - * - *END**************************************************************************/ -void SIM_HAL_DisableCrcClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_CRC(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetCrcGateCmd - * Description : Get the the clock gate state for CRC module - * This function will get the clock gate state for CRC moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetCrcGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC6_CRC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableAdcClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC5_ADC(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableAdcClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC5_ADC(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - retValue = SIM_BRD_SCGC5_ADC(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableCmpClock - * Description : Enable the clock for CMP module - * This function enables the clock for CMP moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableCmpClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC4_CMP(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableCmpClock - * Description : Disable the clock for CMP module - * This function disables the clock for CMP moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableCmpClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC4_CMP(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetCmpGateCmd - * Description : Get the the clock gate state for CMP module - * This function will get the clock gate state for CMP moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetCmpGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC4_CMP(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableDacClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_DAC0(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableDacClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_DAC0(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetDacGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - retValue = SIM_BRD_SCGC6_DAC0(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnablePdbClock - * Description : Enable the clock for PDB module - * This function enables the clock for PDB moudle - * - *END**************************************************************************/ -void SIM_HAL_EnablePdbClock(SIM_Type* base, uint32_t instance) -{ - switch(instance) - { - case 0: - SIM_BWR_SCGC6_PDB0(base, 1); - break; - case 1: - SIM_BWR_SCGC6_PDB1(base, 1); - break; - default: break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisablePdbClock - * Description : Disable the clock for PDB module - * This function disables the clock for PDB moudle - * - *END**************************************************************************/ -void SIM_HAL_DisablePdbClock(SIM_Type* base, uint32_t instance) -{ - switch(instance) - { - case 0: - SIM_BWR_SCGC6_PDB0(base, 0); - break; - case 1: - SIM_BWR_SCGC6_PDB1(base, 0); - break; - default: break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetPdbGateCmd - * Description : Get the the clock gate state for PDB module - * This function will get the clock gate state for PDB moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetPdbGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch(instance) - { - case 0: - retValue = SIM_BRD_SCGC6_PDB0(base); - break; - case 1: - retValue = SIM_BRD_SCGC6_PDB1(base); - break; - default: break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableFtmClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC6_FTM0(base, 1); - break; - case 1: - SIM_BWR_SCGC6_FTM1(base, 1); - break; - case 3: - SIM_BWR_SCGC6_FTM3(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableFtmClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC6_FTM0(base, 0); - break; - case 1: - SIM_BWR_SCGC6_FTM1(base, 0); - break; - case 3: - SIM_BWR_SCGC6_FTM3(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetFtmGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_SCGC6_FTM0(base); - break; - case 1: - retValue = SIM_BRD_SCGC6_FTM1(base); - break; - case 2: - retValue = false; - break; - case 3: - retValue = SIM_BRD_SCGC6_FTM3(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcxMuxSelChannely - * Description : ADC x (0-A, 1-B)channel y (6,7) Mux. - * Refer to RM for specific channel settings - * Selects ADCx MUX0's channel to ADCx channel y. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcxMuxSelChannely(SIM_Type* base, uint32_t instance, - uint8_t channel, uint8_t select) -{ - assert (instance<2); - assert (channel<8); - assert (channel>5); - switch(instance) - { - case 0: - switch(channel) - { - case 6: - SIM_BWR_ADCOPT_ADCACH6SEL(base, select); - break; - case 7: - SIM_BWR_ADCOPT_ADCACH7SEL(base, select); - break; - default: - break; - } - break; - case 1: - switch(channel) - { - case 6: - SIM_BWR_ADCOPT_ADCBCH6SEL(base, select); - break; - case 7: - SIM_BWR_ADCOPT_ADCBCH7SEL(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChOutSrcMode - * Description : Get FlexTimer x channel y output source select setting - * This function will get FlexTimer x channel y output source select - * setting. - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetAdcxMuxSelChannely(SIM_Type* base, uint32_t instance, uint8_t channel) -{ - assert (instance<2); - assert (channel<8); - assert (channel>5); - uint8_t retValue = (uint8_t) false; - switch(instance) - { - case 0: - switch(channel) - { - case 6: - retValue = (uint8_t)SIM_BRD_ADCOPT_ADCACH6SEL(base); - break; - case 7: - retValue = (uint8_t)SIM_BRD_ADCOPT_ADCACH7SEL(base); - break; - default: - retValue = (uint8_t) false; - break; - } - break; - case 3: - switch(channel) - { - case 6: - retValue = (uint8_t)SIM_BRD_ADCOPT_ADCBCH6SEL(base); - break; - case 7: - retValue = (uint8_t)SIM_BRD_ADCOPT_ADCBCH7SEL(base); - break; - default: - retValue = (uint8_t) false; - break; - } - break; - default: - retValue = (uint8_t) false; - break; - } - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetNanoedgeRegulator12SupStdbyControl - * Description : Nanoedge Regulator 1.2 V Supply Standby Control - * This function controls the standby mode of the 1.2 V supply from the nanoedge voltage regulator. - * 00 Nanoedge regulator 1.2 V supply placed in normal mode - * 01 Nanoedge regulator 1.2 V supply placed in standby mode. - * 10 Nanoedge regulator 1.2 V supply placed in normal mode and SR12STDBY is write protected until - * chip reset. - * 11 Nanoedge regulator 1.2 V supply placed in standby mode and SR12STDBY is write protected until - * chip reset. - * - *END**************************************************************************/ -void SIM_HAL_SetNanoedgeRegulator12SupStdbyControl(SIM_Type* base, uint8_t select) -{ - assert (select < 4); - SIM_BWR_PWRC_SR12STDBY(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetNanoedgeRegulator12SupStdbyControl - * Description : Get Nanoedge Regulator 1.2 V Supply Standby Control - * This function will get the standby mode of the 1.2 V supply from the nanoedge voltage regulator - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetNanoedgeRegulator12SupStdbyControl(SIM_Type* base) -{ - return (uint8_t)SIM_BRD_PWRC_SR12STDBY(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetNanoedgeRegulator27SupStdbyControl - * Description : Nanoedge Regulator 2.7 V Supply Standby Control - * This function controls the standby mode of the 2.7 V supply from the nanoedge voltage regulator. - * 00 Nanoedge regulator 2.7 V supply placed in normal mode - * 01 Nanoedge regulator 2.7 V supply placed in standby mode. - * 10 Nanoedge regulator 2.7 V supply placed in normal mode and SR27STDBY is write protected until - * chip reset. - * 11 Nanoedge regulator 2.7 V supply placed in standby mode and SR27STDBY is write protected until - * chip reset. - * - *END**************************************************************************/ -void SIM_HAL_SetNanoedgeRegulator27SupStdbyControl(SIM_Type* base, uint8_t select) -{ - assert (select < 4); - SIM_BWR_PWRC_SR12STDBY(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetNanoedgeRegulator27SupStdbyControl - * Description : Get Nanoedge Regulator 2.7 V Supply Standby Control - * This function will get the standby mode of the 2.7 V supply from the nanoedge voltage regulator - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetNanoedgeRegulator27SupStdbyControl(SIM_Type* base) -{ - return (uint8_t)SIM_BRD_PWRC_SR12STDBY(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetNanoedgeReg27n12SupPwrdwnControl - * Description : Nanoedge Regulator 2.7V and 1.2V Supply Powerdown Control - * This function controls the powerdown mode of the 2.7V and 1.2V supply from the nanoedge voltage regulator - * 00 Nanoedge regulator placed in normal mode. - * 01 Nanoedge regulator placed in powerdown mode. - * 10 Nanoedge regulator placed in normal mode and SRPDN is write protected until chip reset. - * 11 Nanoedge regulator placed in powerdown mode and SRPDN is write protected until chip reset. - * - *END**************************************************************************/ -void SIM_HAL_SetNanoedgeReg27n12SupPwrdwnControl(SIM_Type* base, uint8_t select) -{ - assert (select < 4); - SIM_BWR_PWRC_SRPDN(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetNanoedgeReg27n12SupPwrdwnControl - * Description : Get Nanoedge Regulator 2.7 V Supply Standby Control - * This function will get the standby mode of the 2.7 V supply from the nanoedge voltage regulator - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetNanoedgeReg27n12SupPwrdwnControl(SIM_Type* base) -{ - return (uint8_t)SIM_BRD_PWRC_SRPDN(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetWdogClkSrc - * Description : WDOG Clock Select - * This function selects the clock source of the WDOG2008 watchdog. - * 0 Internal 1 kHz clock is source to WDOG2008 - * 1 MCGIRCLK is source to WDOG2008 - * - *END**************************************************************************/ -void SIM_HAL_SetWdogClkSrc(SIM_Type* base, bool select) -{ - SIM_BWR_WDOGC_WDOGCLKS(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetWdogClkSrc - * Description : Get WDOG Clock setting - * This function will get the clock source of the WDOG2008 watchdog - * - *END**************************************************************************/ -bool SIM_HAL_GetWdogClkSrc(SIM_Type* base) -{ - return (bool)SIM_BRD_WDOGC_WDOGCLKS(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarAPittrigX - * Description : Synchronize XBARA's Input PIT Trigger X with fast clock - * This function controls the synchronizer between PIT trigger X and XBARA's input. - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarAPittrigX(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG0(base, 1); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG1(base, 1); - break; - case 2: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG2(base, 1); - break; - case 3: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG3(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarAPittrigX - * Description : Disable the synchronizer between PIT trigger X and XBARA's input - * This function Disables the synchronizer between PIT trigger X and XBARA's input - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarAPittrigX(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG0(base, 0); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG1(base, 0); - break; - case 2: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG2(base, 0); - break; - case 3: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG3(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarAPittrigXcmd - * Description : Get the synchronizer cmd between PIT trigger X and XBARA's input - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarAPittrigXcmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_MISCTRL2_SYNCXBARAPITTRIG0(base); - break; - case 1: - retValue = SIM_BRD_MISCTRL2_SYNCXBARAPITTRIG1(base); - break; - case 2: - retValue = SIM_BRD_MISCTRL2_SYNCXBARAPITTRIG2(base); - break; - case 3: - retValue = SIM_BRD_MISCTRL2_SYNCXBARAPITTRIG3(base); - break; - default: - retValue = false; - break; - } - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarBPittrigX - * Description : Synchronize XBARB's Input PIT Trigger X with fast clock - * This function controls the synchronizer between PIT trigger X and XBARB's input. - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarBPittrigX(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCXBARBPITTRIG0(base, 1); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCXBARBPITTRIG1(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarBPittrigX - * Description : Disable the synchronizer between PIT trigger X and XBARB's input - * This function Disables the synchronizer between PIT trigger X and XBARB's input - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarBPittrigX(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCXBARBPITTRIG0(base, 0); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCXBARBPITTRIG1(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarBPittrigXcmd - * Description : Get the synchronizer cmd between PIT trigger X and XBARB's input - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarBPittrigXcmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_MISCTRL2_SYNCXBARBPITTRIG0(base); - break; - case 1: - retValue = SIM_BRD_MISCTRL2_SYNCXBARBPITTRIG1(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarDac - * Description : Synchronize XBARA's output for DAC Hardware Trigger with flash/slow clock - * This function controls the synchronizer between XBARA's output and DAC hardware trigger. - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarDac(SIM_Type* base) -{ - SIM_BWR_MISCTRL2_SYNCDACHWTRIG(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarDac - * Description : Disable the synchronizer between XBARA's output and DAC hardware trigger - * This function Disables the synchronizer between XBARA's output and DAC hardware trigger - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarDac(SIM_Type* base) -{ - SIM_BWR_MISCTRL2_SYNCDACHWTRIG(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarDaccmd - * Description : Get the synchronizer cmd between XBARA's output and DAC hardware trigger - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarDaccmd(SIM_Type* base) -{ - return (bool)SIM_BRD_MISCTRL2_SYNCDACHWTRIG(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarEwmin - * Description : Enable the synchronizer between XBARA's output and EWM's ewm_in - * This function enables the synchronizer between XBARA's output and EWM's ewm_in - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarEwmin(SIM_Type* base) -{ - SIM_BWR_MISCTRL2_SYNCEWMIN(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarEwmin - * Description : Disable the synchronizer between XBARA's output and EWM's ewm_in - * This function Disables the synchronizer between XBARA's output and EWM's ewm_in - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarEwmin(SIM_Type* base) -{ - SIM_BWR_MISCTRL2_SYNCEWMIN(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarEwmincmd - * Description : Get the synchronizer cmd between XBARA's output and EWM's ewm_in - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarEwmincmd(SIM_Type* base) -{ - return (bool)SIM_BRD_MISCTRL2_SYNCEWMIN(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarCmpX - * Description : Enable the the synchronizer between XBARA's output and CMP3's sample/window input - * This function enables the the synchronizer between XBARA's output and CMP3's sample/window input - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarCmpX(SIM_Type* base, uint32_t instance) -{ - assert (instance < CMP_INSTANCE_COUNT); - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCCMP0SAMPLEWIN(base, 1); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCCMP1SAMPLEWIN(base, 1); - break; - case 2: - SIM_BWR_MISCTRL2_SYNCCMP2SAMPLEWIN(base, 1); - break; - case 3: - SIM_BWR_MISCTRL2_SYNCCMP3SAMPLEWIN(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarCmpX - * Description : Disable the synchronizer between XBARA's output and CMP3's sample/window input - * This function Disables the synchronizer between XBARA's output and CMP3's sample/window input - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarCmpX(SIM_Type* base, uint32_t instance) -{ - assert (instance < CMP_INSTANCE_COUNT); - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCCMP0SAMPLEWIN(base, 0); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCCMP1SAMPLEWIN(base, 0); - break; - case 2: - SIM_BWR_MISCTRL2_SYNCCMP2SAMPLEWIN(base, 0); - break; - case 3: - SIM_BWR_MISCTRL2_SYNCCMP3SAMPLEWIN(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarCmpXcmd - * Description : Get the synchronizer cmd between XBARA's output and CMP3's sample/window input - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarCmpXcmd(SIM_Type* base, uint32_t instance) -{ - assert (instance < CMP_INSTANCE_COUNT); - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_MISCTRL2_SYNCCMP0SAMPLEWIN(base); - break; - case 1: - retValue = SIM_BRD_MISCTRL2_SYNCCMP1SAMPLEWIN(base); - break; - case 2: - retValue = SIM_BRD_MISCTRL2_SYNCCMP2SAMPLEWIN(base); - break; - case 3: - retValue = SIM_BRD_MISCTRL2_SYNCCMP3SAMPLEWIN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetCmpWinxSrc - * Description : Set CMP Sample/Window Input X Source - * This function controls the sample/window source of CMP module - * - *END**************************************************************************/ -void SIM_HAL_SetCmpWinxSrc(SIM_Type* base, uint32_t instance, - sim_cmp_win_in_src select) -{ - assert (instance < CMP_INSTANCE_COUNT); - switch (instance) - { - case 0: - SIM_BWR_MISCTRL_CMPWIN0SRC(base, select); - break; - case 1: - SIM_BWR_MISCTRL_CMPWIN1SRC(base, select); - break; - case 2: - SIM_BWR_MISCTRL_CMPWIN2SRC(base, select); - break; - case 3: - SIM_BWR_MISCTRL_CMPWIN3SRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetCmpWinxSrc - * Description : Get CMP Sample/Window Input X Source - * This function will get the sample/window source of CMP module - * - *END**************************************************************************/ -sim_cmp_win_in_src SIM_HAL_GetCmpWinxSrc(SIM_Type* base, uint32_t instance) -{ - assert (instance < CMP_INSTANCE_COUNT); - sim_cmp_win_in_src retValue = (sim_cmp_win_in_src)0; - switch (instance) - { - case 0: - retValue = (sim_cmp_win_in_src)SIM_BRD_MISCTRL_CMPWIN0SRC(base); - break; - case 1: - retValue = (sim_cmp_win_in_src)SIM_BRD_MISCTRL_CMPWIN1SRC(base); - break; - case 2: - retValue = (sim_cmp_win_in_src)SIM_BRD_MISCTRL_CMPWIN2SRC(base); - break; - case 3: - retValue = (sim_cmp_win_in_src)SIM_BRD_MISCTRL_CMPWIN3SRC(base); - break; - default: - break; - } - - return retValue; -} - - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetEwmInSrc - * Description : Set EWM_IN source setting - * This function controls the ewm_in source of EWM module - * - *END**************************************************************************/ -void SIM_HAL_SetEwmInSrc(SIM_Type* base, sim_ewm_in_src select) -{ - SIM_BWR_MISCTRL_EWMINSRC(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetEwmInSrc - * Description : Get EWM_IN source setting - * This function will get the ewm_in source of EWM module - * - *END**************************************************************************/ -sim_ewm_in_src SIM_HAL_GetEwmInSrc(SIM_Type* base) -{ - return (sim_ewm_in_src)SIM_BRD_MISCTRL_EWMINSRC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetDacHwTrigSrc - * Description : Set DAC x Hardware trigger source setting - * This function will select the DAC0 Hardware Trigger Input Source - * - *END**************************************************************************/ -void SIM_HAL_SetDacHwTrigSrc(SIM_Type* base,sim_dac_hw_trg_sel select) -{ - SIM_BWR_MISCTRL_DACTRIGSRC(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetDacHwTrigSrc - * Description : Get DAC x Hardware trigger source setting - * This function will get the DAC0 Hardware Trigger Input Source - * - *END**************************************************************************/ -sim_dac_hw_trg_sel SIM_HAL_GetDacHwTrigSrc(SIM_Type* base, uint32_t instance) -{ - return (sim_dac_hw_trg_sel)SIM_BRD_MISCTRL_DACTRIGSRC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance) -{ - return (sim_ftm_clk_sel_t)0; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel) -{ - return (sim_ftm_ch_src_t)0; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChOutSrcMode - * Description : FlexTimer x channel y output source select setting. - * This function will select FlexTimer x channel y output source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChOutSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_out_src_t select) -{ - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChOutSrcMode - * Description : Get FlexTimer x channel y output source select setting - * This function will get FlexTimer x channel y output source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_out_src_t SIM_HAL_GetFtmChOutSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel) -{ - return (sim_ftm_ch_out_src_t)0; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmCarrierFreqCmd - * Description : Set FTMxCFSELBIT - * This function sets FlexTimer x carrier frequency selection software configuration setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmCarrierFreqCmd(SIM_Type* base, uint32_t instance, bool ftmcarrierfreqsrc) -{ - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmCarrierFreqCmd - * Description : Get FlexTimer x carrier frequency selection software configuration setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetFtmCarrierFreqCmd(SIM_Type* base, uint32_t instance) -{ - return true; -} -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmSyncCmd - * Description : Set FTMxSYNCBIT - * This function sets FlexTimer x hardware trigger 0 software synchronization. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmSyncCmd(SIM_Type* base, uint32_t instance, bool sync) -{ - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type* base, - sim_cadc_conv_id_t convId, - sim_adc_alt_trg_en enable) -{ - switch (convId) - { - case kSimCAdcConvA: - SIM_BWR_SOPT7_ADCAALTTRGEN(base, enable); - break; - case kSimCAdcConvB: - SIM_BWR_SOPT7_ADCBALTTRGEN(base, enable); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -sim_adc_alt_trg_en SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type* base, sim_cadc_conv_id_t convId) -{ - sim_adc_alt_trg_en retValue = (sim_adc_alt_trg_en)false; - - switch (convId) - { - case kSimCAdcConvA: - retValue = (sim_adc_alt_trg_en)SIM_BRD_SOPT7_ADCAALTTRGEN(base); - break; - case kSimCAdcConvB: - retValue = (sim_adc_alt_trg_en)SIM_BRD_SOPT7_ADCBALTTRGEN(base); - break; - default: - retValue = (sim_adc_alt_trg_en)false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type* base, - sim_cadc_conv_id_t convId, - sim_adc_trg_sel_t select) -{ - switch (convId) - { - case kSimCAdcConvA: - SIM_BWR_SOPT7_ADCATRGSEL(base, select); - break; - case kSimCAdcConvB: - SIM_BWR_SOPT7_ADCBTRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type* base, sim_cadc_conv_id_t convId) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - switch (convId) - { - case kSimCAdcConvA: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADCATRGSEL(base); - break; - case kSimCAdcConvB: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADCBTRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type* base, - sim_cadc_conv_id_t convId, - bool altTrigEn, - sim_adc_trg_sel_t trigSel) -{ - switch (convId) - { - case kSimCAdcConvA: - SIM_BWR_SOPT7_ADCAALTTRGEN(base, altTrigEn ? 1 : 0); - break; - case kSimCAdcConvB: - SIM_BWR_SOPT7_ADCBALTTRGEN(base, altTrigEn ? 1 : 0); - break; - default: - break; - } - - if (altTrigEn) - { - switch (convId) - { - case kSimCAdcConvA: - SIM_BWR_SOPT7_ADCATRGSEL(base, trigSel); - break; - case kSimCAdcConvB: - SIM_BWR_SOPT7_ADCBTRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type* base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type* base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type* base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type* base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t trigger) -{ - return (sim_ftm_trg_src_t)0; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type* base, - uint8_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type* base, - uint8_t instance, - uint8_t fault) -{ - return (sim_ftm_flt_sel_t)0; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnablePitClock - * Description : Enable the clock for PIT module - * This function enables the clock for PIT moudle - * - *END**************************************************************************/ -void SIM_HAL_EnablePitClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_PIT(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisablePitClock - * Description : Disable the clock for PIT module - * This function disables the clock for PIT moudle - * - *END**************************************************************************/ -void SIM_HAL_DisablePitClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_PIT(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetPitGateCmd - * Description : Get the the clock gate state for PIT module - * This function will get the clock gate state for PIT moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetPitGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC6_PIT(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableLptmrClock - * Description : Enable the clock for LPTIMER module - * This function enables the clock for LPTIMER moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableLptmrClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC5_LPTMR(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableLptmrClock - * Description : Disable the clock for LPTIMER module - * This function disables the clock for LPTIMER moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableLptmrClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC5_LPTMR(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetLptmrGateCmd - * Description : Get the the clock gate state for LPTIMER module - * This function will get the clock gate state for LPTIMER moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetLptmrGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC5_LPTMR(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableFlexcanClock - * Description : Enable the clock for FLEXCAN module - * This function enables the clock for FLEXCAN moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableFlexcanClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC6_FLEXCAN0(base, 1); - break; - case 1: - SIM_BWR_SCGC6_FLEXCAN1(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableFlexcanClock - * Description : Disable the clock for FLEXCAN module - * This function disables the clock for FLEXCAN moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableFlexcanClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC6_FLEXCAN0(base, 0); - break; - case 1: - SIM_BWR_SCGC6_FLEXCAN1(base, 0); - break; - default: - break; - } - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFlexcanGateCmd - * Description : Get the the clock gate state for FLEXCAN module - * This function will get the clock gate state for FLEXCAN moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetFlexcanGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_SCGC6_FLEXCAN0(base); - break; - case 1: - retValue = SIM_BRD_SCGC6_FLEXCAN1(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableSpiClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC6_SPI0(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableSpiClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC6_SPI0(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetSpiGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_SCGC6_SPI0(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableI2cClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC4_I2C0(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableI2cClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC4_I2C0(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetI2cGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_SCGC4_I2C0(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableUartClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC4_UART0(base, 1); - break; - case 1: - SIM_BWR_SCGC4_UART1(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function disables the clock for UART moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableUartClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC4_UART0(base, 0); - break; - case 1: - SIM_BWR_SCGC4_UART1(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetUartGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_SCGC4_UART0(base); - break; - case 1: - retValue = SIM_BRD_SCGC4_UART1(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnablePwmClock - * Description : Enable the clock for eFlexPWM module - * This function enables the clock for eFlexPWM moudle - * - *END**************************************************************************/ -void SIM_HAL_EnablePwmClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC4_eFlexPWM0(base, 1); - break; - case 1: - SIM_BWR_SCGC4_eFlexPWM1(base, 1); - break; - case 2: - SIM_BWR_SCGC4_eFlexPWM2(base, 1); - break; - case 3: - SIM_BWR_SCGC4_eFlexPWM3(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisablePwmClock - * Description : Disable the clock for eFlexPWM module - * This function disables the clock for eFlexPWM moudle - * - *END**************************************************************************/ -void SIM_HAL_DisablePwmClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC4_eFlexPWM0(base, 0); - break; - case 1: - SIM_BWR_SCGC4_eFlexPWM1(base, 0); - break; - case 2: - SIM_BWR_SCGC4_eFlexPWM2(base, 0); - break; - case 3: - SIM_BWR_SCGC4_eFlexPWM3(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetPwmGateCmd - * Description : Get the the clock gate state for eFlexPWM module - * This function will get the clock gate state for eFlexPWM moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetPwmGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_SCGC4_eFlexPWM0(base); - break; - case 1: - retValue = SIM_BRD_SCGC4_eFlexPWM1(base); - break; - case 2: - retValue = SIM_BRD_SCGC4_eFlexPWM2(base); - break; - case 3: - retValue = SIM_BRD_SCGC4_eFlexPWM3(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableAoiClock - * Description : Enable the clock for AOI module - * This function enables the clock for AOI moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableAoiClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC5_AOI(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableAoiClock - * Description : Disable the clock for AOI module - * This function disables the clock for AOI moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableAoiClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC5_AOI(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAoiGateCmd - * Description : Get the the clock gate state for AOI module - * This function will get the clock gate state for AOI moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetAoiGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC5_AOI(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableXbarClock - * Description : Enable the clock for XBAR module - * This function enables the clock for XBAR moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableXbarClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC5_XBARA(base, 1); - break; - case 1: - SIM_BWR_SCGC5_XBARB(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableXbarClock - * Description : Disable the clock for XBAR module - * This function disables the clock for XBAR moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableXbarClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC5_XBARA(base, 0); - break; - case 1: - SIM_BWR_SCGC5_XBARB(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetXbarGateCmd - * Description : Get the the clock gate state for XBAR module - * This function will get the clock gate state for XBAR moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetXbarGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_SCGC5_XBARA(base); - break; - case 1: - retValue = SIM_BRD_SCGC5_XBARB(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableEncClock - * Description : Enable the clock for ENC module - * This function enables the clock for ENC moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableEncClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC5_ENC(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableEncClock - * Description : Disable the clock for ENC module - * This function disables the clock for ENC moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableEncClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC5_ENC(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetEncGateCmd - * Description : Get the the clock gate state for ENC module - * This function will get the clock gate state for ENC moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetEncGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC5_ENC(base); -} -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKV43F15/fsl_sim_hal_MKV43F15.h b/KSDK_1.2.0/platform/hal/src/sim/MKV43F15/fsl_sim_hal_MKV43F15.h deleted file mode 100644 index 6da523a..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKV43F15/fsl_sim_hal_MKV43F15.h +++ /dev/null @@ -1,3018 +0,0 @@ -/* - * Copyright (c) 2014 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_KV43F15_H__) -#define __FSL_SIM_HAL_KV43F15_H__ - -/*! @addtogroup sim_hal*/ -/*! @{*/ -#include "fsl_sim_hal.h" -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/*! @brief WDOG clock source select */ -typedef enum _clock_wdog_src_t -{ - kClockWdogSrcLpoClk, /*!< LPO */ - kClockWdogSrcAltClk, /*!< Alternative clock, for K64F12 it is Bus clock. */ -} clock_wdog_src_t; - -/*! @brief Debug trace clock source select */ -typedef enum _clock_trace_src_t -{ - kClockTraceSrcMcgoutClk, /*!< MCG out clock */ - kClockTraceSrcCoreClk, /*!< core clock */ -} clock_trace_src_t; - -/*! @brief Debug trace clock source select */ -typedef enum _clock_nanoedge_clk2x_src -{ - kClockNanoedgeSrcMcgPllClk, /*!< MCG out clock */ - kClockNanoedgeSrcMcgPllClk2x, /*!< core clock */ -} clock_nanoedge_clk2x_src; - -/*! @brief SIM OSC32KSEL clock source select */ -typedef enum _sim_osc32k_clock_sel -{ - kSimOsc32kSelOsc32k, /* OSC 32k clock */ - kSimOsc32kSelReserved, /* Reserved */ - kSimOsc32kSelReserved1, /* Reserved */ - kSimOsc32kSelLpo /* LPO clock */ -} sim_osc32k_clock_sel_t; - -/*! @brief SIM NANOEDGECLK2XSEL clock source select */ -typedef enum _sim_nanoedge_clock_sel -{ - kSimNanoEdgeMcgPllClk, /* MCG PLL clock */ - kSimNanoEdgeMcgPll2xClk, /* MCG PLL 2X clock */ -} sim_nanoedge_clock_sel_t; - -/*! @brief SIM TRACECLKSEL clock source select */ -typedef enum _sim_trace_clock_sel -{ - kSimTraceMcgoutClk, /* MCG out clock */ - kSimTraceCoreClk /* core clock */ -} sim_trace_clock_sel_t; - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _sim_clkout_clock_sel -{ - kSimClkoutReserved, /* Reserved */ - kSimClkoutReserved1, /* Reserved */ - kSimClkoutFlashClk, /* Flash clock */ - kSimClkoutLpoClk, /* LPO clock */ - kSimClkoutMcgIrcClk, /* MCG out clock */ - kSimClkoutOscErcClkUndiv, /* Undivided OSC ERC clock */ - kSimClkoutOscErcClk /* OSC ERC clock */ - -} sim_clkout_clock_sel_t; - -/*! @brief SIM ADCB trigger select */ -typedef enum _sim_adcb_trg_sel -{ - kSimAdcbTrgSelHighSpeedComp0 = 1U, /* High speed comparator 0 output */ - kSimAdcbTrgSelHighSpeedComp1 = 2U, /* High speed comparator 1 output */ - kSimAdcbTrgSelHighSpeedComp2 = 3U, /* High speed comparator 2 output */ - kSimAdcbTrgSelPit0 = 4U, /* PIT trigger 0 */ - kSimAdcbTrgSelPit1 = 5U, /* PIT trigger 1 */ - kSimAdcbTrgSelPit2 = 6U, /* PIT trigger 2 */ - kSimAdcbTrgSelPit3 = 7U, /* PIT trigger 3 */ - kSimAdcbTrgSelFtm0 = 8U, /* FTM0 trigger */ - kSimAdcbTrgSelFtm1 = 9U, /* FTM1 trigger */ - kSimAdcbTrgSelFtm3 = 11U, /* FTM3 trigger */ - kSimAdcbTrgSelxbaraout41 = 12U, /* XBARAOUT41 */ - kSimAdcbTrgSelLptimer = 14U, /* Low-power timer trigger */ -} sim_adcb_trg_sel_t; - -/*! @brief SIM ADC trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselPdb0Ext = 0U, /* PDB0_EXTRG for ADCA, Reserved for ADCB */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /* High speed comparator 0 output */ - kSimAdcTrgSelHighSpeedComp1 = 2U, /* High speed comparator 1 output */ - kSimAdcTrgSelHighSpeedComp2 = 3U, /* High speed comparator 2 output */ - kSimAdcTrgSelPit0 = 4U, /* PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /* PIT trigger 1 */ - kSimAdcTrgSelPit2 = 6U, /* PIT trigger 2 */ - kSimAdcTrgSelPit3 = 7U, /* PIT trigger 3 */ - kSimAdcTrgSelFtm0 = 8U, /* FTM0 trigger */ - kSimAdcTrgSelFtm1 = 9U, /* FTM1 trigger */ - kSimAdcTrgSelFtm3 = 11U, /* FTM3 trigger */ - kSimAdcTrgSelxbaraout = 12U, /* XBARAOUT38 for ADCA & XBAROUT41 for ADCB */ - kSimAdcTrgSelLptimer = 14U, /* Low-power timer trigger */ -} sim_adc_trg_sel_t; - -/*! - * @brief Defines the type of enumerating ADC converter's ID. - */ -typedef enum _sim_cadc_conv_id -{ - kSimCAdcConvA = 0U,/*!< ID for ADC converter A. */ - kSimCAdcConvB = 1U /*!< ID for ADC converter B. */ -} sim_cadc_conv_id_t; - -/*! @brief SIM ADC alternate trigger enable */ -typedef enum _sim_adc_alt_trg_en -{ - kSimAdcTrgenXbarout = 0U, /* XBARAOUT12 for ADCA, XBARAOUT13 for ADCB */ - kSimAdcTrgenPdb = 1U, /* PDB0 for ADCA, PDB1 for ADCB */ - kSimAdcTrgenalt0 = 2U, /* alternate trigger enable */ - kSimAdcTrgenalt1 = 3U, /* High speed comparator 2 output */ -} sim_adc_alt_trg_en; - -/*! @brief DAC0 Hardware Trigger Input Source */ -typedef enum _sim_dac_hw_trg_sel -{ - kSimDacHwTrgSelXbarout15 = 0U, /* XBARA output 15 */ - kSimDacHwTrgSelPdb01Int = 1U, /* both PDB0 interval trigger 0 and PDB1 interval trigger 0 */ - kSimDacHwTrgSelPdb0Int = 2U, /* PDB0 interval trigger 0 */ - kSimDacHwTrgSelPdb1Int = 3U, /* PDB1 interval trigger 0 */ -} sim_dac_hw_trg_sel; - -/*! @brief the ewm_in source of EWM module. */ -typedef enum _sim_ewm_in_src -{ - kSimDacHwTrgSelXbarout58 = 0U, /* XBARA output 58 */ - kSimDacHwTrgSelEwnInPin = 1U, /* EWM_IN Pin */ -} sim_ewm_in_src; - -/*! @brief CMP Sample/Window Input X Source*/ -typedef enum _sim_cmp_win_in_src -{ - kSimCmpWinInSrcXbarout = 0U, /* XBARA output - Refer RM for specific module */ - kSimCmpWinInSrcPdb01Int = 1U, /* CMP0 Sample/Window input driven by both PDB0 and PDB1 pluse-out channel 0 */ - kSimCmpWinInSrcPdb0Int = 2U, /* PDB0 interval trigger 0 */ - kSimCmpWinInSrcPdb1Int = 3U, /* PDB1 interval trigger 0 */ -} sim_cmp_win_in_src; - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCGIRCLK */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClkUndiv, /*!< OSCERCLK_UNDIV clock */ -} clock_lptmr_src_t; - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcLpo = 3U, /*!< LPO clock. */ -} clock_er32k_src_t; - -/*! @brief FLEXCAN clock source select */ -typedef enum _clock_flexcan_src_t -{ - kClockFlexcanSrcOsc0erClk, /*!< OSCERCLK */ - kClockFlexcanSrcBusClk /*!< Bus clock */ -} clock_flexcan_src_t; - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateEwm0 = FSL_SIM_SCGC_BIT(4U, 1U), - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateUart0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateCmp = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGatePwm0 = FSL_SIM_SCGC_BIT(4U, 24U), - kSimClockGatePwm1 = FSL_SIM_SCGC_BIT(4U, 25U), - kSimClockGatePwm2 = FSL_SIM_SCGC_BIT(4U, 26U), - kSimClockGatePwm3 = FSL_SIM_SCGC_BIT(4U, 27U), - - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - kSimClockGateEnc0 = FSL_SIM_SCGC_BIT(5U, 21U), - kSimClockGateXbarA = FSL_SIM_SCGC_BIT(5U, 25U), - kSimClockGateXbarB = FSL_SIM_SCGC_BIT(5U, 26U), - kSimClockGateAoi0 = FSL_SIM_SCGC_BIT(5U, 27U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(5U, 28U), - - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateFlexcan0 = FSL_SIM_SCGC_BIT(6U, 4U), - kSimClockGateFlexcan1 = FSL_SIM_SCGC_BIT(6U, 5U), - kSimClockGateFtm3 = FSL_SIM_SCGC_BIT(6U, 6U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(6U, 12U), - kSimClockGatePdb1 = FSL_SIM_SCGC_BIT(6U, 17U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), - kSimClockGatePdb0 = FSL_SIM_SCGC_BIT(6U, 22U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateFtm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateFtm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(6U, 31U), - - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 8U), -} sim_clock_gate_name_t; - -/*! @brief Clock source and sel names */ -typedef enum _clock_source_names { - kClockNfcSrc, /* NFCSRC*/ - kClockEsdhcSrc, /* ESDHCSRC K70*/ - kClockSdhcSrc, /* SDHCSRC K64*/ - kClockLcdcSrc, /* LCDCSRC*/ - kClockTimeSrc, /* TIMESRC*/ - kClockRmiiSrc, /* RMIISRC*/ - kClockUsbfSrc, /* USBFSRC K70*/ - kClockUsbSrc, /* USBSRC K64, KL25, KV31, and K22*/ - kClockUsbhSrc, /* USBHSRC*/ - kClockUart0Src, /* UART0SRC*/ - kClockLpuartSrc, /* LPUARTSRC K22, KV31 */ - kClockTpmSrc, /* TPMSRC*/ - kClockOsc32kSel, /* OSC32KSEL*/ - kClockUsbfSel, /* USBF_CLKSEL*/ - kClockPllfllSel, /* PLLFLLSEL*/ - kClockNfcSel, /* NFC_CLKSEL*/ - kClockLcdcSel, /* LCDC_CLKSEL*/ - kClockTraceSel, /* TRACE_CLKSEL*/ - kClockClkoutSel, /* CLKOUTSEL*/ - kClockRtcClkoutSel, /* RTCCLKOUTSEL */ - kClockNanoEdgeClk2xSel, /* NANOEDGECLK2XSEL */ - kClockSourceMax -} clock_source_names_t; - -/*! @brief Clock Divider names*/ -typedef enum _clock_divider_names { - kClockDividerOutdiv1, /* OUTDIV1*/ - kClockDividerOutdiv2, /* OUTDIV2*/ - kClockDividerOutdiv3, /* OUTDIV3*/ - kClockDividerOutdiv4, /* OUTDIV4*/ - kClockDividerUsbFrac, /* (USBFRAC + 1) / (USBDIV + 1)*/ - kClockDividerUsbDiv, - kClockDividerUsbfsFrac, /* (USBFSFRAC + 1) / (USBFSDIV) + 1)*/ - kClockDividerUsbfsDiv, - kClockDividerUsbhsFrac, /* (USBHSFRAC + 1) / (USBHSDIV + 1)*/ - kClockDividerUsbhsDiv, - kClockDividerLcdcFrac, /* (LCDCFRAC + 1) / (LCDCDIV + 1)*/ - kClockDividerLcdcDiv, - kClockDividerNfcFrac, /* (NFCFRAC + 1) / (NFCDIV + 1)*/ - kClockDividerNfcDiv, - kClockDividerSpecial1, /* special divider 1*/ - kClockDividerMax -} clock_divider_names_t; - - - -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_stop -{ - kSimUsbsstbyNoRegulator, /* regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /* regulator in standby during Stop modes */ -} sim_usbsstby_stop_t; - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_stop -{ - kSimUsbvstbyNoRegulator, /* regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /* regulator in standby during VLPR and VLPW modes */ -} sim_usbvstby_stop_t; - -/*! @brief SIM CMT/UART pad drive strength */ -typedef enum _sim_cmtuartpad_strengh -{ - kSimCmtuartSinglePad, /* Single-pad drive strength for CMT IRO or UART0_TXD */ - kSimCmtuartDualPad /* Dual-pad drive strength for CMT IRO or UART0_TXD */ -} sim_cmtuartpad_strengh_t; - -/*! @brief SIM PTD7 pad drive strength */ -typedef enum _sim_ptd7pad_strengh -{ - kSimPtd7padSinglePad, /* Single-pad drive strength for PTD7 */ - kSimPtd7padDualPad /* Dual-pad drive strength for PTD7 */ -} sim_ptd7pad_strengh_t; - -/*! @brief SIM FlexBus security level */ -typedef enum _sim_flexbus_security_level -{ - kSimFbslLevel0, /* All off-chip accesses (op code and data) via the FlexBus */ - /* and DDR controller are disallowed */ - kSimFbslLevel1, /* Undefined */ - kSimFbslLevel2, /* Off-chip op code accesses are disallowed. Data accesses */ - /* are allowed */ - kSimFbslLevel3 /* Off-chip op code accesses and data accesses are allowed */ -} sim_flexbus_security_level_t; - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /* UARTx_RX Pin */ - kSimUartRxsrcCmp0, /* CMP0 */ - kSimUartRxsrcCmp1, /* CMP1 */ - kSimUartRxsrcReserved /* Reserved */ -} sim_uart_rxsrc_t; - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /* UARTx_TX Pin */ - kSimUartTxsrcFtm1, /* UARTx_TX pin modulated with FTM1 channel 0 output */ -} sim_uart_txsrc_t; - -/*! @brief SIM FlexTimer x trigger y select */ -typedef enum _sim_ftm_trg_src -{ - kSimFtmTrgSrc0, /* FlexTimer x trigger y select 0 */ - kSimFtmTrgSrc1 /* FlexTimer x trigger y select 1 */ -} sim_ftm_trg_src_t; - -/*! @brief SIM FlexTimer external clock select */ -typedef enum _sim_ftm_clk_sel -{ - kSimFtmClkSel0, /* FTM CLKIN0 pin. */ - kSimFtmClkSel1, /* FTM CLKIN1 pin. */ - kSimFtmClkSel2 /* FTM CLKIN2 pin. */ -} sim_ftm_clk_sel_t; - -/*! @brief SIM FlexTimer x channel y input capture source select */ -typedef enum _sim_ftm_ch_src -{ - kSimFtmChSrc0, /* See RM for details of each selection for each channel */ - kSimFtmChSrc1, /* See RM for details of each selection for each channel */ - kSimFtmChSrc2, /* See RM for details of each selection for each channel */ - kSimFtmChSrc3 /* See RM for details of each selection for each channel */ -} sim_ftm_ch_src_t; - -/*! @brief SIM FlexTimer x channel y output source select */ -typedef enum _sim_ftm_ch_out_src -{ - kSimFtmChOutSrc0, - kSimFtmChOutSrc1, -} sim_ftm_ch_out_src_t; - -/*! @brief SIM FlexTimer x Fault y select */ -typedef enum _sim_ftm_flt_sel -{ - kSimFtmFltSel0, /* FlexTimer x fault y select 0 */ - kSimFtmFltSel1 /* FlexTimer x fault y select 1 */ -} sim_ftm_flt_sel_t; - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /* Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /* Timer/PWM TPM_CLKIN1 pin. */ -} sim_tpm_clk_sel_t; - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /* TPMx_CH0 signal */ - kSimTpmChSrc1 /* CMP0 output */ -} sim_tpm_ch_src_t; - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ -/*! - * @brief Sets the clock source setting. - * - * This function sets the settings for a specified clock source. Each clock - * source has its own clock selection settings. See the chip reference manual for - * clock source detailed settings and the clock_source_names_t - * for clock sources. - * - * @param base Base address for current SIM instance. - * @param clockSource Clock source name defined in sim_clock_source_names_t - * @param setting Setting value - * @return status If the clock source doesn't exist, it returns an error. - */ -sim_hal_status_t CLOCK_HAL_SetSource(SIM_Type* base, clock_source_names_t clockSource, uint8_t setting); - -/*! - * @brief Gets the clock source setting. - * - * This function gets the settings for a specified clock source. Each clock - * source has its own clock selection settings. See the reference manual for - * clock source detailed settings and the clock_source_names_t - * for clock sources. - * - * @param base Base address for current SIM instance. - * @param clockSource Clock source name - * @param setting Current setting for the clock source - * @return status If the clock source doesn't exist, it returns an error. - */ -sim_hal_status_t CLOCK_HAL_GetSource(SIM_Type* base, clock_source_names_t clockSource, - uint8_t *setting); - -/*! - * @brief Sets the clock divider setting. - * - * This function sets the setting for a specified clock divider. See the - * reference manual for a supported clock divider and value range and the - * clock_divider_names_t for dividers. - * - * @param base Base address for current SIM instance. - * @param clockDivider Clock divider name - * @param setting Divider setting - * @return status If the clock divider doesn't exist, it returns an error. - */ -sim_hal_status_t CLOCK_HAL_SetDivider(SIM_Type* base, clock_divider_names_t clockDivider, - uint32_t setting); - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * See the reference manual for a supported clock divider and value range and the - * clock_divider_names_t for clock out dividers. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type* base, uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type* base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -/*@}*/ - -/*! @name individual field access APIs*/ -/*@{*/ - -#if FSL_FEATURE_SIM_OPT_HAS_RAMSIZE -/*! - * @brief Gets RAM size. - * - * This function gets the RAM size. The field specifies the amount of system RAM - * available on the device. - * - * @param base Base address for current SIM instance. - * @return size RAM size on the device - */ -static inline uint32_t SIM_HAL_GetRamSize(SIM_Type* base) -{ - return SIM_BRD_SOPT1_RAMSIZE(base); -} -#endif /* FSL_FEATURE_SIM_OPT_HAS_RAMSIZE */ - -#if FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type* base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type* base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type* base, - sim_usbsstby_stop_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_stop_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type* base) -{ - return (sim_usbsstby_stop_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type* base, - sim_usbvstby_stop_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_stop_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type* base) -{ - return (sim_usbvstby_stop_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type* base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type* base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type* base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type* base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type* base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type* base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif - -#if FSL_FEATURE_SIM_OPT_HAS_CMTUARTPAD -/*! - * @brief Sets the CMT/UART pad drive strength setting. - * - * This function controls the output drive strength of the CMT IRO signal or - * UART0_TXD signal on PTD7 pin by selecting either one or two pads to drive it. - * - * @param base Base address for current SIM instance. - * @param setting CMT/UART pad drive strength setting - * - 0: Single-pad drive strength for CMT IRO or UART0_TXD. - * - 1: Dual-pad drive strength for CMT IRO or UART0_TXD. - */ -static inline void SIM_HAL_SetCmtUartPadDriveStrengthMode(SIM_Type* base, - sim_cmtuartpad_strengh_t setting) -{ - SIM_BWR_SOPT2_CMTUARTPAD(base, setting); -} - -/*! - * @brief Gets the CMT/UART pad drive strength setting. - * - * This function gets the CMT/UART pad drive strength setting. - * - * @param base Base address for current SIM instance. - * @return setting CMT/UART pad drive strength setting - */ -static inline sim_cmtuartpad_strengh_t SIM_HAL_GetCmtUartPadDriveStrengthMode(SIM_Type* base) -{ - return (sim_cmtuartpad_strengh_t)SIM_BRD_SOPT2_CMTUARTPAD(base); -} -#endif /* FSL_FEATURE_SIM_OPT_HAS_CMTUARTPAD */ - -#if FSL_FEATURE_SIM_OPT_HAS_PTD7PAD -/*! - * @brief Sets the PTD7 pad drive strength setting. - * - * This function controls the output drive strength of the PTD7 pin by selecting - * either one or two pads to drive it. - * - * @param base Base address for current SIM instance. - * @param setting PTD7 pad drive strength setting - * - 0: Single-pad drive strength for PTD7. - * - 1: Double pad drive strength for PTD7. - */ -static inline void SIM_HAL_SetPtd7PadDriveStrengthMode(SIM_Type* base, - sim_ptd7pad_strengh_t setting) -{ - SIM_BWR_SOPT2_PTD7PAD(base, setting); -} - -/*! - * @brief Gets the PTD7 pad drive strength setting. - * - * This function gets the PTD7 pad drive strength setting. - * - * @param base Base address for current SIM instance. - * @return setting PTD7 pad drive strength setting - */ -static inline sim_ptd7pad_strengh_t SIM_HAL_GetPtd7PadDriveStrengthMode(SIM_Type* base) -{ - return (sim_ptd7pad_strengh_t)SIM_BRD_SOPT2_PTD7PAD(base); -} -#endif /* FSL_FEATURE_SIM_OPT_HAS_PTD7PAD */ - -#if FSL_FEATURE_SIM_OPT_HAS_FBSL -/*! - * @brief Sets the FlexBus security level setting. - * - * This function sets the FlexBus security level setting. If the security is enabled, - * this field affects which CPU operations can access the off-chip via the FlexBus - * and DDR controller interfaces. This field has no effect if the security is not enabled. - * - * @param base Base address for current SIM instance. - * @param setting FlexBus security level setting - * - 00: All off-chip accesses (op code and data) via the FlexBus and - * DDR controller are disallowed. - * - 10: Off-chip op code accesses are disallowed. Data accesses are - * allowed. - * - 11: Off-chip op code accesses and data accesses are allowed. - */ -static inline void SIM_HAL_SetFlexbusSecurityLevelMode(SIM_Type* base, - sim_flexbus_security_level_t setting) -{ - SIM_BWR_SOPT2_FBSL(base, setting); -} - -/*! - * @brief Gets the FlexBus security level setting. - * - * This function gets the FlexBus security level setting. - * - * @param base Base address for current SIM instance. - * @return setting FlexBus security level setting - */ -static inline sim_flexbus_security_level_t SIM_HAL_GetFlexbusSecurityLevelMode(SIM_Type* base) -{ - return (sim_flexbus_security_level_t)SIM_BRD_SOPT2_FBSL(base); -} -#endif /* FSL_FEATURE_SIM_OPT_HAS_FBSL */ - -#if FSL_FEATURE_SIM_OPT_HAS_PCR -/*! - * @brief Sets the PCR setting. - * - * This function sets the PCR setting. This is the FlexBus hold cycles before - * FlexBus can release bus to NFC or to IDLE. - * - * @param base Base address for current SIM instance. - * @param setting PCR setting - */ -static inline void SIM_HAL_SetFlexbusHoldCycles(SIM_Type* base, uint32_t setting) -{ - SIM_BWR_SOPT6_PCR(base, setting); -} - -/*! - * @brief Gets the PCR setting. - * - * This function gets the PCR setting. - * - * @param base Base address for current SIM instance. - * @return setting PCR setting - */ -static inline uint32_t SIM_HAL_GetFlexbusHoldCycles(SIM_Type* base) -{ - return SIM_BRD_SOPT6_PCR(base); -} -#endif /* FSL_FEATURE_SIM_OPT_HAS_PCR */ - -#if FSL_FEATURE_SIM_OPT_HAS_MCC -/*! - * @brief Sets the MCC setting. - * - * This function sets the MCC setting. This is the NFC hold cycle in case the - * FlexBus request during NFC is granted. - * - * @param base Base address for current SIM instance. - * @param setting MCC setting - */ -static inline void SIM_HAL_SetNandFlashControllerHoldCycles(SIM_Type* base, uint32_t setting) -{ - SIM_BWR_SOPT6_MCC(base, setting); -} - -/*! - * @brief Gets the MCC setting. - * - * This function gets the MCC setting. - * - * @param base Base address for current SIM instance. - * @return setting MCC setting - */ -static inline uint32_t SIM_HAL_GetNandFlashControllerHoldCycles(SIM_Type* base) -{ - return SIM_BRD_SOPT6_MCC(base); -} -#endif /* FSL_FEATURE_SIM_OPT_HAS_MCC */ - -/*! - * @brief Sets the FlexTimer x external clock pin select setting. - * - * This function selects the source of FTMx external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select FTMx external clock pin select - * - 0: FTMx external clock driven by FTM CLKIN0 pin. - * - 1: FTMx external clock driven by FTM CLKIN1 pin. - */ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance, - sim_ftm_clk_sel_t select); - -/*! - * @brief Gets the FlexTimer x external clock pin select setting. - * - * This function gets the FlexTimer x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select FlexTimer x external clock pin select setting - */ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance); - -/*! - * @brief Sets the FlexTimer x channel y input capture source select setting. - * - * This function selects the FlexTimer x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y input capture source - */ -void SIM_HAL_SetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y input capture source select setting. - * - * This function gets the FlexTimer x channel y input capture - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y input capture source select setting - */ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Sets the FlexTimer x channel y output source select setting. - * - * This function selects the FlexTimer x channel y output source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y output source - */ -void SIM_HAL_SetFtmChOutSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_out_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y output source select setting. - * - * This function gets the FlexTimer x channel y output - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y output source select setting - */ -sim_ftm_ch_out_src_t SIM_HAL_GetFtmChOutSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief sets FlexTimer x carrier frequency selection setting - * - * This function sets the FTMx output channel carrier frequency selection setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param ftmcarrierfreqsrc FTMx output channel carrier frequency selection - */ -void SIM_HAL_SetFtmCarrierFreqCmd(SIM_Type* base, uint32_t instance, bool ftmcarrierfreqsrc); - -/*! - * @brief Gets the FlexTimer x carrier frequency selection setting. - * - * This function gets the FTMx output channel carrier frequency selection setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return value indicates FTMx output channel carrier frequency selection - */ -bool SIM_HAL_GetFtmCarrierFreqCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief sets FlexTimer x hardware trigger 0 software synchronization - * - * This function enables/disables the alternative hardware triggers for FTMx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param sync assert TRIG0 input to FTM0 - */ -void SIM_HAL_SetFtmSyncCmd(SIM_Type* base, uint32_t instance, bool sync); - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param convId Selection of ID for ADC converter. - * @param enable Enable alternative conversion triggers for ADCx - * - Enable an alternative conversion trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type* base, sim_cadc_conv_id_t convId, sim_adc_alt_trg_en enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param convId Selection of ID for ADC converter. - * @return value indicates ADCx alternate trigger selection - */ -sim_adc_alt_trg_en SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type* base, sim_cadc_conv_id_t convId); - - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param convId Selection of ID for ADC converter. - * @param select trigger select setting for ADCx - * - 0000: External trigger - * - 0001: High speed comparator 0 asynchronous interrupt - * - 0010: High speed comparator 1 asynchronous interrupt - * - 0011: High speed comparator 2 asynchronous interrupt - * - 0100: PIT trigger 0 - * - 0101: PIT trigger 1 - * - 0110: PIT trigger 2 - * - 0111: PIT trigger 3 - * - 1000: FTM0 trigger - * - 1001: FTM1 trigger - * - 1010: FTM2 trigger - * - 1011: FTM3 trigger - * - 1100: RTC alarm - * - 1101: RTC seconds - * - 1110: Low-power timer trigger - * - 1111: High speed comparator 3 asynchronous interrupt -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type* base, sim_cadc_conv_id_t convId, sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param convId Selection of ID for ADC converter. - * @return select ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type* base, sim_cadc_conv_id_t convId); - -/*! - * @brief Set ADCx trigger setting. - * - * This function sets ADC alternate trigger and trigger mode. - * - * @param base Base address for current SIM instance. - * @param convId device instance. - * @param altTrigEn alternate trigger enable - * @param trigSel 00 XBARA output 12, 01 PDB0 trigger selected for ADCA, 1- Alternate trigger selected for ADCA. - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type* base, sim_cadc_conv_id_t convId, - bool altTrigEn, sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - * - 00: UARTx_RX pin. - * - 01: CMP0. - * - 10: CMP1. - * - 11: Reserved. - */ -void SIM_HAL_SetUartRxSrcMode(SIM_Type* base, uint32_t instance, sim_uart_rxsrc_t select); - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type* base, uint32_t instance); - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - * - 00: UARTx_TX pin. - * - 01: UARTx_TX pin modulated with FTM1 channel 0 output. - * - 10: UARTx_TX pin modulated with FTM2 channel 0 output. - * - 11: Reserved. - */ -void SIM_HAL_SetUartTxSrcMode(SIM_Type* base, uint32_t instance, sim_uart_txsrc_t select); - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type* base, uint32_t instance); - -#if FSL_FEATURE_SIM_OPT_HAS_ODE -/*! - * @brief Sets the UARTx Open Drain Enable setting. - * - * This function enables/disables the UARTx Open Drain. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable/disable UARTx Open Drain - * - True: Enable UARTx Open Drain - * - False: Disable UARTx Open Drain - */ -void SIM_HAL_SetUartOpenDrainCmd(SIM_Type* base, uint8_t instance, bool enable); - -/*! - * @brief Gets the UARTx Open Drain Enable setting. - * - * This function gets the UARTx Open Drain Enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if UARTx Open Drain is enabled. - */ -bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type* base, uint8_t instance); -#endif - -#if FSL_FEATURE_SIM_OPT_HAS_FTM -/*! - * @brief Sets the FlexTimer x hardware trigger y source select setting. - * - * This function selects the source of FTMx hardware trigger y. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @param select FlexTimer x hardware trigger y - * - 0: Pre-trigger A selected for ADCx. - * - 1: Pre-trigger B selected for ADCx. - */ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select); - -/*! - * @brief Gets the FlexTimer x hardware trigger y source select setting. - * - * This function gets the FlexTimer x hardware trigger y source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @return select FlexTimer x hardware trigger y source select setting - */ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type* base, uint32_t instance, uint8_t trigger); - -/*! - * @brief Sets the FlexTimer x fault y select setting. - * - * This function sets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @param select FlexTimer x fault y select setting - * - 0: FlexTimer x fault y select 0. - * - 1: FlexTimer x fault y select 1. - */ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type* base, uint8_t instance, uint8_t fault, sim_ftm_flt_sel_t select); - -/*! - * @brief Gets the FlexTimer x fault y select setting. - * - * This function gets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @return select FlexTimer x fault y select setting - */ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type* base, uint8_t instance, uint8_t fault); -#endif - -#if FSL_FEATURE_SIM_OPT_HAS_TPM -/*! - * @brief Sets the Timer/PWM x external clock pin select setting. - * - * This function selects the source of the Timer/PWM x external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select Timer/PWM x external clock pin select - * - 0: Timer/PWM x external clock driven by the TPM_CLKIN0 pin. - * - 1: Timer/PWM x external clock driven by the TPM_CLKIN1 pin. - */ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type* base, uint8_t instance, sim_tpm_clk_sel_t select); - -/*! - * @brief Gets the Timer/PWM x external clock pin select setting. - * - * This function gets the Timer/PWM x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select Timer/PWM x external clock pin select setting - */ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type* base, uint8_t instance); - -/*! - * @brief Sets the Timer/PWM x channel y input capture source select setting. - * - * This function selects the Timer/PWM x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel TPM channel y - * @param select Timer/PWM x channel y input capture source - * - 0: TPMx_CH0 signal - * - 1: CMP0 output - */ -void SIM_HAL_SetTpmChSrcMode(SIM_Type* base, uint8_t instance, uint8_t channel, sim_tpm_ch_src_t select); - -/*! - * @brief Gets the Timer/PWM x channel y input capture source select setting. - * - * This function gets the Timer/PWM x channel y input capture source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel Tpm channel y - * @return select Timer/PWM x channel y input capture source select setting - */ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type* base, uint8_t instance, uint8_t channel); -#endif - -#if FSL_FEATURE_SIM_SDID_HAS_FAMILYID -/*! - * @brief Gets the Kinetis Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Family ID in the System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Family ID - */ -static inline uint32_t SIM_HAL_GetFamilyId(SIM_Type* base) -{ - return SIM_BRD_SDID_FAMILYID(base); -} -#endif - -#if FSL_FEATURE_SIM_SDID_HAS_SUBFAMID -/*! - * @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Sub-Family ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Sub-Family ID - */ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type* base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} -#endif - -#if FSL_FEATURE_SIM_SDID_HAS_SERIESID -/*! - * @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Series ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Series ID - */ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type* base) -{ - return SIM_BRD_SDID_SERIESID(base); -} -#endif - -#if FSL_FEATURE_SIM_SDID_HAS_FAMID -/*! - * @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Fam ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Fam ID - */ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type* base) -{ - return SIM_BRD_SDID_FAMID(base); -} -#endif - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type* base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type* base) -{ - return SIM_BRD_SDID_REVID(base); -} - -#if FSL_FEATURE_SIM_SDID_HAS_DIEID -/*! - * @brief Gets the Kinetis Die ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Die ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Die ID - */ -static inline uint32_t SIM_HAL_GetDieId(SIM_Type* base) -{ - return SIM_BRD_SDID_DIEID(base); -} -#endif - -#if FSL_FEATURE_SIM_SDID_HAS_SRAMSIZE -/*! - * @brief Gets the Kinetis SRAM size in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis SRAM Size in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis SRAM Size - */ -static inline uint32_t SIM_HAL_GetSramSize(SIM_Type* base) -{ - return SIM_BRD_SDID_SRAMSIZE(base); -} -#endif - -#if FSL_FEATURE_SIM_FCFG_HAS_NVMSIZE -/*! - * @brief Gets the FlexNVM size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size FlexNVM Size - */ -static inline uint32_t SIM_HAL_GetFlexnvmSize(SIM_Type* base) -{ - return SIM_BRD_FCFG1_NVMSIZE(base); -} -#endif - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type* base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -#if FSL_FEATURE_SIM_FCFG_HAS_EESIZE -/*! - * @brief Gets the EEProm size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the EEProm size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size EEProm Size - */ -static inline uint32_t SIM_HAL_GetEepromSize(SIM_Type* base) -{ - return SIM_BRD_FCFG1_EESIZE(base); -} -#endif - -#if FSL_FEATURE_SIM_FCFG_HAS_DEPART -/*! - * @brief Gets the FlexNVM partition in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM partition in the Flash Configuration Register 1 - * - * @param base Base address for current SIM instance. - * @return setting FlexNVM partition setting - */ -static inline uint32_t SIM_HAL_GetFlexnvmPartition(SIM_Type* base) -{ - return SIM_BRD_FCFG1_DEPART(base); -} -#endif - -#if FSL_FEATURE_SIM_FCFG_HAS_FLASHDOZE -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type* base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type* base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} -#endif - -#if FSL_FEATURE_SIM_FCFG_HAS_FLASHDIS -/*! - * @brief Sets the Flash disable setting in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash disable setting in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type* base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash disable setting in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type* base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} -#endif - -#if FSL_FEATURE_SIM_FCFG_HAS_MAXADDR0 -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type* base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} -#endif - -#if FSL_FEATURE_SIM_FCFG_HAS_MAXADDR1 -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type* base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} -#endif - -#if FSL_FEATURE_SIM_FCFG_HAS_MAXADDR01 -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock01(SIM_Type* base) -{ - return SIM_BRD_FCFG2_MAXADDR01(base); -} -#endif - -#if FSL_FEATURE_SIM_FCFG_HAS_MAXADDR23 -/*! - * @brief Gets the Flash maximum address block 1 in the Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock23(SIM_Type* base) -{ - return SIM_BRD_FCFG2_MAXADDR23(base); -} -#endif - -#if FSL_FEATURE_SIM_FCFG_HAS_PFLSH -/*! - * @brief Gets the program flash in the Flash Configuration Register 2. - * - * This function gets the program flash maximum block 0 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return status program flash status - */ -static inline uint32_t SIM_HAL_GetProgramFlashCmd(SIM_Type* base) -{ - return SIM_BRD_FCFG2_PFLSH(base); -} -#endif - -/*! - * @brief Sets the Debug Trace Divider Control. - * - * This function sets the Debug Trace Divider enable setting. - * - * @param base Base address for current SIM instance. - * @param enable Debug trace divider control enable setting - */ -static inline void SIM_HAL_SetDebugTraceDivEnCmd(SIM_Type* base, bool enable) -{ - SIM_BWR_CLKDIV4_TRACEDIVEN(base, enable); -} - -/*! - * @brief Gets the Debug Trace Divider Control. - * - * This function gets the Debug Trace Divider enable setting. - * - * @param base Base address for current SIM instance. - * @return enable Debug trace divider control enable setting - */ -static inline bool SIM_HAL_GetDebugTraceDivEnCmd(SIM_Type* base) -{ - return (bool)SIM_BRD_CLKDIV4_TRACEDIVEN(base); -} - -/*! - * @brief Sets the Debug Trace Divider Divisor. - * - * This function sets the Debug Trace Divider Divisor value. - * - * @param base Base address for current SIM instance. - * @param divisor_value divide value for the fractional clock divider - */ -static inline void SIM_HAL_SetDebugTraceDivDivisor(SIM_Type* base, uint8_t divisor_value) -{ - SIM_BWR_CLKDIV4_TRACEDIV(base, divisor_value); -} - -/*! - * @brief Gets the Debug Trace Divider Divisor value. - * - * This function gets the Debug Trace Divider enable setting. - * - * @param base Base address for current SIM instance. - * @return divisor_value divide value for the fractional clock divider - */ -static inline uint8_t SIM_HAL_GetDebugTraceDivDivisor(SIM_Type* base) -{ - return (bool)SIM_BRD_CLKDIV4_TRACEDIV(base); -} - -/*! - * @brief Sets the Debug Trace Divider Divisor. - * - * This function sets the Debug Trace Divider Divisor value. - * - * @param base Base address for current SIM instance. - * @param divisor_frac_value divide value for the fractional clock divider - */ -static inline void SIM_HAL_SetDebugTraceFracDivDivisor(SIM_Type* base, bool divisor_frac_value) -{ - SIM_BWR_CLKDIV4_TRACEFRAC(base, divisor_frac_value); -} - -/*! - * @brief Gets the Debug Trace Divider Divisor value. - * - * This function gets the Debug Trace Divider enable setting. - * - * @param base Base address for current SIM instance. - * @return divisor_frac_value divide value for the fractional clock divider - */ -static inline uint8_t SIM_HAL_GetDebugTraceFracDivDivisor(SIM_Type* base) -{ - return (bool)SIM_BRD_CLKDIV4_TRACEFRAC(base); -} - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type* base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type* base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type* base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! @name IP related clock feature APIs*/ -/*@{*/ -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type* base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type* base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV2. - * - * This function sets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv2(SIM_Type* base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV2(base, setting); -} - -/*! - * @brief Get OUTDIV2. - * - * This function gets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv2(SIM_Type* base) -{ - return SIM_BRD_CLKDIV1_OUTDIV2(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type* base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type* base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableDmaClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableDmaClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetDmaGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableDmamuxClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableDmamuxClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetDmamuxGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnablePortClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisablePortClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetPortGateCmd(SIM_Type* base, uint32_t instance); - - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableEwmClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableEwmClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetEwmGateCmd(SIM_Type* base, uint32_t instance); - - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableFtfClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableFtfClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetFtfGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableCrcClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableCrcClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetCrcGateCmd(SIM_Type* base, uint32_t instance); - - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableAdcClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableAdcClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetAdcGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableCmpClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableCmpClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetCmpGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableDacClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableDacClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetDacGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnablePdbClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisablePdbClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetPdbGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableFtmClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableFtmClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetFtmGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Set the ADC x (0-A, 1-B)channel y (6,7) Mux - * - * This function selects ADCx MUXy's channel to ADCx channel y. - * - * - * @param base Base address for current SIM instance. - * @param instance ADC module instance (0-A, 1-B) - * @param channel channel number (6,7) - * @param select Refer to RM for specific channel settings - * - *END**************************************************************************/ -void SIM_HAL_SetAdcxMuxSelChannely(SIM_Type* base, uint32_t instance, - uint8_t channel, uint8_t select); - -/*! - * @brief Get the ADC x (0-A, 1-B)channel y (6,7) Mux - * - * This function gets the ADCx MUXy's channel to ADCx channel y. - * - * - * @param base Base address for current SIM instance. - * @param instance ADC module instance (0-A, 1-B) - * @param channel channel number (6,7) - * @return select Refer to RM for specific channel settings - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetAdcxMuxSelChannely(SIM_Type* base, uint32_t instance, uint8_t channel); - -/*! - * @brief Set Nanoedge Regulator 1.2 V Supply Standby Control - * - * This function controls the standby mode of the 1.2 V supply from the nanoedge voltage regulator. - * - * @param base Base address for current SIM instance. - * @param select: - * 00 Nanoedge regulator 1.2 V supply placed in normal mode - * 01 Nanoedge regulator 1.2 V supply placed in standby mode. - * 10 Nanoedge regulator 1.2 V supply placed in normal mode and SR12STDBY is write protected until - * chip reset. - * 11 Nanoedge regulator 1.2 V supply placed in standby mode and SR12STDBY is write protected until - * chip reset. - * - *END**************************************************************************/ -void SIM_HAL_SetNanoedgeRegulator12SupStdbyControl(SIM_Type* base, uint8_t select); - -/*! - * - * @brief Get Nanoedge Regulator 1.2 V Supply Standby Control - * - * This function will get the standby mode of the 1.2 V supply from the nanoedge voltage regulator - * @param base Base address for current SIM instance. - * @return select: - * 00 Nanoedge regulator 1.2 V supply placed in normal mode - * 01 Nanoedge regulator 1.2 V supply placed in standby mode. - * 10 Nanoedge regulator 1.2 V supply placed in normal mode and SR12STDBY is write protected until - * chip reset. - * 11 Nanoedge regulator 1.2 V supply placed in standby mode and SR12STDBY is write protected until - * chip reset. - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetNanoedgeRegulator12SupStdbyControl(SIM_Type* base); - -/*! - * @brief Set Nanoedge Regulator 2.7 V Supply Standby Control - * - * This function controls the standby mode of the 2.7 V supply from the nanoedge voltage regulator. - * - * @param base Base address for current SIM instance. - * @param select: - * 00 Nanoedge regulator 2.7 V supply placed in normal mode - * 01 Nanoedge regulator 2.7 V supply placed in standby mode. - * 10 Nanoedge regulator 2.7 V supply placed in normal mode and SR12STDBY is write protected until - * chip reset. - * 11 Nanoedge regulator 2.7 V supply placed in standby mode and SR12STDBY is write protected until - * chip reset. - * - * - *END**************************************************************************/ -void SIM_HAL_SetNanoedgeRegulator27SupStdbyControl(SIM_Type* base, uint8_t select); - -/*! - * @brief Get Nanoedge Regulator 2.7 V Supply Standby Control - * - * This function will get the standby mode of the 2.7 V supply from the nanoedge voltage regulator. - * - * @param base Base address for current SIM instance. - * @return select: - * 00 Nanoedge regulator 2.7 V supply placed in normal mode - * 01 Nanoedge regulator 2.7 V supply placed in standby mode. - * 10 Nanoedge regulator 2.7 V supply placed in normal mode and SR12STDBY is write protected until - * chip reset. - * 11 Nanoedge regulator 2.7 V supply placed in standby mode and SR12STDBY is write protected until - * chip reset. - * - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetNanoedgeRegulator27SupStdbyControl(SIM_Type* base); - -/*! - * - * @brief Set Nanoedge Regulator 2.7V and 1.2V Supply Powerdown Control - * - * This function controls the powerdown mode of the 2.7V and 1.2V supply from the nanoedge voltage regulator - * - * @param base Base address for current SIM instance. - * @param select: - * 00 Nanoedge regulator placed in normal mode. - * 01 Nanoedge regulator placed in powerdown mode. - * 10 Nanoedge regulator placed in normal mode and SRPDN is write protected until chip reset. - * 11 Nanoedge regulator placed in powerdown mode and SRPDN is write protected until chip reset. - * - *END**************************************************************************/ -void SIM_HAL_SetNanoedgeReg27n12SupPwrdwnControl(SIM_Type* base, uint8_t select); - -/*! - * - * @brief Get Nanoedge Regulator 2.7V and 1.2V Supply Powerdown Control - * - * This function gets the the powerdown mode of the 2.7V and 1.2V supply from the nanoedge voltage regulator - * - * @param base Base address for current SIM instance. - * @return select: - * 00 Nanoedge regulator placed in normal mode. - * 01 Nanoedge regulator placed in powerdown mode. - * 10 Nanoedge regulator placed in normal mode and SRPDN is write protected until chip reset. - * 11 Nanoedge regulator placed in powerdown mode and SRPDN is write protected until chip reset. - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetNanoedgeReg27n12SupPwrdwnControl(SIM_Type* base); - -/*! - * - * @brief WDOG Clock Select - * - * This function selects the clock source of the WDOG2008 watchdog. - * - * @param base Base address for current SIM instance. - * @param select: - * 0 Internal 1 kHz clock is source to WDOG2008 - * 1 MCGIRCLK is source to WDOG2008 - * - *END**************************************************************************/ -void SIM_HAL_SetWdogClkSrc(SIM_Type* base, bool select); - -/*! - * - * @brief Get WDOG Clock Src - * - * This function gets the clock source of the WDOG2008 watchdog. - * - * @param base Base address for current SIM instance. - * @return select: - * 0 Internal 1 kHz clock is source to WDOG2008 - * 1 MCGIRCLK is source to WDOG2008 - * - *END**************************************************************************/ -bool SIM_HAL_GetWdogClkSrc(SIM_Type* base); - -/*! - * - * @brief Synchronize XBARA's Input PIT Trigger X with fast clock - * - * This function enables the synchronizer between PIT trigger X and XBARA's input. - * - * @param base Base address for current SIM instance. - * @param instance Pit trigger number - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarAPittrigX(SIM_Type* base, uint32_t instance); - -/*! - * - * @brief Synchronize XBARA's Input PIT Trigger X with fast clock - * - * This function disables the synchronizer between PIT trigger X and XBARA's input. - * - * @param base Base address for current SIM instance. - * @param instance Pit trigger number - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarAPittrigX(SIM_Type* base, uint32_t instance); - -/*! - * - * @brief get Synchronization of XBARA's Input PIT Trigger X with fast clock - * - * This function returns the status of the synchronizer between PIT trigger X and XBARA's input. - * - * @param base Base address for current SIM instance. - * @param instance Pit trigger number - * @return 0 - Not synchronizeed, 1- Synchronized - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarAPittrigXcmd(SIM_Type* base, uint32_t instance); - -/*! - * - * @brief Synchronize XBARB's Input PIT Trigger X with fast clock - * - * This function enables the synchronizer between PIT trigger X and XBARB's input. - * - * @param base Base address for current SIM instance. - * @param instance Pit trigger number - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarBPittrigX(SIM_Type* base, uint32_t instance); - -/*! - * - * @brief Synchronize XBARB's Input PIT Trigger X with fast clock - * - * This function disables the synchronizer between PIT trigger X and XBARB's input. - * - * @param base Base address for current SIM instance. - * @param instance Pit trigger number - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarBPittrigX(SIM_Type* base, uint32_t instance); - -/*! - * - * @brief get Synchronization of XBARB's Input PIT Trigger X with fast clock - * - * This function returns the status of the synchronizer between PIT trigger X and XBARB's input. - * - * @param base Base address for current SIM instance. - * @param instance Pit trigger number - * @return 0 - Not synchronizeed, 1- Synchronized - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarBPittrigXcmd(SIM_Type* base, uint32_t instance); - -/*! - * - * @brief Synchronize XBARA's output for DAC Hardware Trigger with flash/slow clock - * - * This function controls the synchronizer between XBARA's output and DAC hardware trigger. - * - * @param base Base address for current SIM instance. - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarDac(SIM_Type* base); - -/*! - * - * @brief Synchronize XBARA's output for DAC Hardware Trigger with flash/slow clock - * - * This function Disables the synchronizer between XBARA's output and DAC hardware trigger - * - * @param base Base address for current SIM instance. - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarDac(SIM_Type* base); - -/*! - * - * @brief Get the synchronizer cmd between XBARA's output and DAC hardware trigger - * - * @param base Base address for current SIM instance. - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarDaccmd(SIM_Type* base); - -/*! - * - * @brief Get the synchronizer cmd between XBARA's output and EWM's ewm_in - * - * This function enables the synchronizer between XBARA's output and EWM's ewm_in - * - * @param base Base address for current SIM instance. - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarEwmin(SIM_Type* base); - -/*! - * - * @brief Disable the synchronizer between XBARA's output and EWM's ewm_in - * - * This function Disables the synchronizer between XBARA's output and EWM's ewm_in - * - * @param base Base address for current SIM instance. - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarEwmin(SIM_Type* base); - -/*! - * - * @brief Get the synchronizer cmd between XBARA's output and EWM's ewm_in - * - * @param base Base address for current SIM instance. - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarEwmincmd(SIM_Type* base); - -/*! - * - * @brief Enable the the synchronizer between XBARA's output and CMPx's sample/window input - * - * This function enables the the synchronizer between XBARA's output and CMPx's sample/window input - * - * @param base Base address for current SIM instance. - * @param instance comaprator instance - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarCmpX(SIM_Type* base, uint32_t instance); - -/*! - * - * @brief Disable the synchronizer between XBARA's output and CMP3's sample/window input - * - * This function Disables the synchronizer between XBARA's output and CMP3's sample/window input - * - * @param base Base address for current SIM instance. - * @param instance comaprator instance - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarCmpX(SIM_Type* base, uint32_t instance); - -/*! - * - * @brief Get the synchronizer cmd between XBARA's output and CMP3's sample/window input - * - * @param base Base address for current SIM instance. - * @param instance comaprator instance - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarCmpXcmd(SIM_Type* base, uint32_t instance); - -/*! - * - * @brief Set CMP Sample/Window Input X Source - * - * This function controls the sample/window source of CMP module - * - * @param base Base address for current SIM instance. - * @param instance comaprator instance - * @param select CMP Sample/Window Input X Source - * 00 XBARA output - refer RM for specific cmp instance - * 01 CMPx Sample/Window input is driven by both PDB0 and PDB1 pluse-out channel 0. - * 10 PDB0 pluse-out channel 0. - * 11 PDB1 pluse-out channel 0. - *END**************************************************************************/ -void SIM_HAL_SetCmpWinxSrc(SIM_Type* base, uint32_t instance, - sim_cmp_win_in_src select); - -/*! - * - * @brief Get CMP Sample/Window Input X Source - * - * This function will get the sample/window source of CMP module - * - * @param base Base address for current SIM instance. - * @param instance comaprator instance - * @return select CMP Sample/Window Input X Source - * 00 XBARA output - refer RM for specific cmp instance - * 01 CMPx Sample/Window input is driven by both PDB0 and PDB1 pluse-out channel 0. - * 10 PDB0 pluse-out channel 0. - * 11 PDB1 pluse-out channel 0. - *END**************************************************************************/ -sim_cmp_win_in_src SIM_HAL_GetCmpWinxSrc(SIM_Type* base, uint32_t instance); - -/*! - * - * @brief Set EWM_IN source setting - * - * This function controls the ewm_in source of EWM module - * - * @param base Base address for current SIM instance. - * @param select EWM_IN source , 0-XBARA output 58, 1-EWM_IN pin - * - *END**************************************************************************/ -void SIM_HAL_SetEwmInSrc(SIM_Type* base, sim_ewm_in_src select); - -/*! - * - * @brief Get EWM_IN source setting - * - * This function will get the ewm_in source of EWM module - * @param base Base address for current SIM instance. - * @return select EWM_IN source , 0-XBARA output 58, 1-EWM_IN pin - * - *END**************************************************************************/ -sim_ewm_in_src SIM_HAL_GetEwmInSrc(SIM_Type* base); - -/*! - * - * @brief Set DAC x Hardware trigger source setting - * - * This function will select the DAC0 Hardware Trigger Input Source - * - * @param base Base address for current SIM instance. - * @param select DAC0 Hardware Trigger Input Source - * 00 XBARA output 15. - * 01 DAC0 can be triggered by both PDB0 interval trigger 0 and PDB1 interval trigger 0. - * 10 PDB0 interval trigger 0 - * 11 PDB1 interval trigger 0 - *END**************************************************************************/ -void SIM_HAL_SetDacHwTrigSrc(SIM_Type* base,sim_dac_hw_trg_sel select); - -/*! - * - * @brief Get DAC x Hardware trigger source setting - * - * This function will get the DAC0 Hardware Trigger Input Source - * - * @param base Base address for current SIM instance. - * @param instance DAC instance. - * @return select DAC0 Hardware Trigger Input Source - * 00 XBARA output 15. - * 01 DAC0 can be triggered by both PDB0 interval trigger 0 and PDB1 interval trigger 0. - * 10 PDB0 interval trigger 0 - * 11 PDB1 interval trigger 0 - *END**************************************************************************/ -sim_dac_hw_trg_sel SIM_HAL_GetDacHwTrigSrc(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnablePitClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisablePitClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetPitGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableLptmrClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableLptmrClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetLptmrGateCmd(SIM_Type* base, uint32_t instance); - - -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableFlexcanClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableFlexcanClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetFlexcanGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableSpiClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableSpiClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetSpiGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableI2cClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableI2cClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetI2cGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableUartClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableUartClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetUartGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for eFlexPWM module. - * - * This function enables the clock for eFlexPWM moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnablePwmClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for eFlexPWM module. - * - * This function disables the clock for eFlexPWM moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisablePwmClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for eFlexPWM module. - * - * This function will get the clock gate state for eFlexPWM moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetPwmGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for AOI module. - * - * This function enables the clock for AOI moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableAoiClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for AOI module. - * - * This function disables the clock for AOI moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableAoiClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for AOI module. - * - * This function will get the clock gate state for AOI moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetAoiGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for XBAR module. - * - * This function enables the clock for XBAR moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableXbarClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for XBAR module. - * - * This function disables the clock for XBAR moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableXbarClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for XBAR module. - * - * This function will get the clock gate state for XBAR moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetXbarGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for ENC module. - * - * This function enables the clock for ENC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableEncClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for ENC module. - * - * This function disables the clock for ENC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableEncClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for ENC module. - * - * This function will get the clock gate state for ENC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetEncGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type* base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type* base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set debug trace clock selection. - * - * This function sets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTraceClkSrc(SIM_Type* base, clock_trace_src_t setting) -{ - SIM_BWR_SOPT2_TRACECLKSEL(base, setting); -} - -/*! - * @brief Get debug trace clock selection. - * - * This function gets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_trace_src_t CLOCK_HAL_GetTraceClkSrc(SIM_Type* base) -{ - return (clock_trace_src_t)SIM_BRD_SOPT2_TRACECLKSEL(base); -} - -/*! - * @brief Set Nanoedge clock selection. - * - * This function sets Nanoedge clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetNanoedgeClkSrc(SIM_Type* base, clock_nanoedge_clk2x_src setting) -{ - SIM_BWR_SOPT2_NANOEDGECLK2XSEL(base, setting); -} - -/*! - * @brief Get Nanoedge clock selection. - * - * This function gets Nanoedge clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_nanoedge_clk2x_src CLOCK_HAL_GetNanoedgeClkSrc(SIM_Type* base) -{ - return (clock_nanoedge_clk2x_src)SIM_BRD_SOPT2_NANOEDGECLK2XSEL(base); -} - -/*! - * @brief Get Nanoedge PMC Status - * - * This function gets Nanoedge power supply status. - * - * @param base Base address for current SIM instance. - * @return power supply status. - */ -static inline bool CLOCK_HAL_GetNanoedgePMCStatus(SIM_Type* base) -{ - return (bool)SIM_BRD_PWRC_SRPWROK(base); -} -/*@}*/ - -/*! - * @brief Set Nanoedge PMC POWER Ready - * - * This function sets soft control to indicate nanoedge PMC is ready, - * when PMC Power dectect is disabled by SRPWRDETEN - * @param base Base address for current SIM instance. - * @param select power supply status. - */ -static inline void CLOCK_HAL_SetNanoedgePMCPwrRdy(SIM_Type* base, bool select) -{ - SIM_BWR_PWRC_SRPWRRDY(base, select); -} - -/*! - * @brief Get Nanoedge PMC POWER Ready - * - * This function gets soft control to indicate nanoedge PMC is ready. - * - * @param base Base address for current SIM instance. - * @return power supply status. - */ -static inline bool CLOCK_HAL_GetNanoedgePMCPwrRdy(SIM_Type* base) -{ - return (bool)SIM_BRD_PWRC_SRPWRRDY(base); -} -/*@}*/ - -/*! - * @brief Nanoedge PMC POWER Dectect Enable - * - * enable Nanoedge PMC power dectect to assert PMC ready signal when PMC is stable. - * - * @param base Base address for current SIM instance. - * - */ -static inline void CLOCK_HAL_EnableNanoedgePmcPowerDectect (SIM_Type* base) -{ - SIM_BWR_PWRC_SRPWRDETEN(base, 1); -} - -/*! - * @brief Nanoedge PMC POWER Dectect Disable - * - * disable Nanoedge PMC power dectect to assert PMC ready signal when PMC is stable. - * - * @param base Base address for current SIM instance. - * - */ -static inline void CLOCK_HAL_DisableNanoedgePmcPowerDectect (SIM_Type* base) -{ - SIM_BWR_PWRC_SRPWRDETEN(base, 0); -} - -/*! - * @brief Get Nanoedge PMC POWER Dectect - * - * This function gets Nanoedge PMC power dectect to assert PMC ready signal when PMC is stable - * - * @param base Base address for current SIM instance. - * @return PMC power dectect status. - */ -static inline bool CLOCK_HAL_GetNanoedgePmcPowerDectectcmd(SIM_Type* base) -{ - return (bool)SIM_BRD_PWRC_SRPWRDETEN(base); -} - -/*! - * @brief Get ADC Clock Status - * - * This function returns which clock is fed in ADC. - * 0 ADC clock is fast peripherial clock. - * 1 ADC clock is MCGIRCLK. - * - * @param base Base address for current SIM instance. - * @return ADC Clock Status. - */ -static inline bool CLOCK_HAL_GetAdcClkStatus(SIM_Type* base) -{ - return (bool)SIM_BRD_ADCOPT_ADCIRCLK(base); -} - -/*! - * @brief Enable ADC low current Mode - * - * Control ADC low current mode in STOP and VLPS mode. - * - * @param base Base address for current SIM instance. - * - */ -static inline void CLOCK_HAL_EnableAdcLowCurrentMode(SIM_Type* base) -{ - SIM_BWR_ADCOPT_ROSB(base, 1); -} - -/*! - * @brief Disable ADC low current Mode - * - * Control ADC low current mode in STOP and VLPS mode. - * - * @param base Base address for current SIM instance. - * - */ -static inline void CLOCK_HAL_DisableAdcLowCurrentMode(SIM_Type* base) -{ - SIM_BWR_ADCOPT_ROSB(base, 0); -} - -/*! - * @brief Get ADC low current Mode - * - * This function gets ADC low current mode in STOP and VLPS mode. - * - * @param base Base address for current SIM instance. - * @return ADC low current mode status. - */ -static inline bool CLOCK_HAL_GetAdcLowCurrentModecmd(SIM_Type* base) -{ - return (bool)SIM_BRD_ADCOPT_ROSB(base); -} -/*@}*/ - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - - -/*! @}*/ - -#endif /* __FSL_SIM_HAL_KV43F15_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKV44F15/fsl_sim_hal_MKV44F15.c b/KSDK_1.2.0/platform/hal/src/sim/MKV44F15/fsl_sim_hal_MKV44F15.c deleted file mode 100755 index b3fc495..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKV44F15/fsl_sim_hal_MKV44F15.c +++ /dev/null @@ -1,2274 +0,0 @@ -/* - * Copyright (c) 2014 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type* base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type* base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableDmaClock - * Description : Enable the clock for DMA module - * This function enables the clock for DMA moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableDmaClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC7_DMA(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableDmaClock - * Description : Disable the clock for DMA module - * This function disables the clock for DMA moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableDmaClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC7_DMA(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetDmaGateCmd - * Description : Get the the clock gate state for DMA module - * This function will get the clock gate state for DMA moudle - * - *END**************************************************************************/ -bool SIM_HAL_GetDmaGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC7_DMA(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableDmamuxClock - * Description : Enable the clock for DMAMUX module - * This function enables the clock for DMAMUX moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableDmamuxClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_DMAMUX(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableDmamuxClock - * Description : Disable the clock for DMAMUX module - * This function disables the clock for DMAMUX moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableDmamuxClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_DMAMUX(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetDmamuxGateCmd - * Description : Get the the clock gate state for DMAMUX module - * This function will get the clock gate state for DMAMUX moudle - * - *END**************************************************************************/ -bool SIM_HAL_GetDmamuxGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC6_DMAMUX(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void SIM_HAL_EnablePortClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC5_PORTA(base, 1); - break; - case 1: - SIM_BWR_SCGC5_PORTB(base, 1); - break; - case 2: - SIM_BWR_SCGC5_PORTC(base, 1); - break; - case 3: - SIM_BWR_SCGC5_PORTD(base, 1); - break; - case 4: - SIM_BWR_SCGC5_PORTE(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void SIM_HAL_DisablePortClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC5_PORTA(base, 0); - break; - case 1: - SIM_BWR_SCGC5_PORTB(base, 0); - break; - case 2: - SIM_BWR_SCGC5_PORTC(base, 0); - break; - case 3: - SIM_BWR_SCGC5_PORTD(base, 0); - break; - case 4: - SIM_BWR_SCGC5_PORTE(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetPortGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_SCGC5_PORTA(base); - break; - case 1: - retValue = SIM_BRD_SCGC5_PORTB(base); - break; - case 2: - retValue = SIM_BRD_SCGC5_PORTC(base); - break; - case 3: - retValue = SIM_BRD_SCGC5_PORTD(base); - break; - case 4: - retValue = SIM_BRD_SCGC5_PORTE(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableEwmClock - * Description : Enable the clock for EWM module - * This function enables the clock for EWM moudle. - * - *END**************************************************************************/ -void SIM_HAL_EnableEwmClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC4_EWM(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableEwmClock - * Description : Disable the clock for EWM modul - * This function disables the clock for EWM moudle. - * - *END**************************************************************************/ -void SIM_HAL_DisableEwmClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC4_EWM(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetEwmGateCmd - * Description : Get the the clock gate state for EWM module - * This function will get the clock gate state for EWM moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetEwmGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC4_EWM(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableFtfClock - * Description : Enable the clock for FTF module - * This function enables the clock for FTF moudle. - * - *END**************************************************************************/ -void SIM_HAL_EnableFtfClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_FTF(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableFtfClock - * Description : Disable the clock for FTF module - * This function disables the clock for FTF moudle. - * - *END**************************************************************************/ -void SIM_HAL_DisableFtfClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_FTF(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtfGateCmd - * Description : Get the the clock gate state for FTF module - * This function will get the clock gate state for FTF moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetFtfGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC6_FTF(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableCrcClock - * Description : Enable the clock for CRC module - * This function enables the clock for CRC moudle. - * - *END**************************************************************************/ -void SIM_HAL_EnableCrcClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_CRC(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableCrcClock - * Description : Disable the clock for CRC module - * This function disables the clock for CRC moudle. - * - *END**************************************************************************/ -void SIM_HAL_DisableCrcClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_CRC(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetCrcGateCmd - * Description : Get the the clock gate state for CRC module - * This function will get the clock gate state for CRC moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetCrcGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC6_CRC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableAdcClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC5_ADC(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableAdcClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC5_ADC(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - retValue = SIM_BRD_SCGC5_ADC(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableCmpClock - * Description : Enable the clock for CMP module - * This function enables the clock for CMP moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableCmpClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC4_CMP(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableCmpClock - * Description : Disable the clock for CMP module - * This function disables the clock for CMP moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableCmpClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC4_CMP(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetCmpGateCmd - * Description : Get the the clock gate state for CMP module - * This function will get the clock gate state for CMP moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetCmpGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC4_CMP(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableDacClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_DAC0(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableDacClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_DAC0(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetDacGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - retValue = SIM_BRD_SCGC6_DAC0(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnablePdbClock - * Description : Enable the clock for PDB module - * This function enables the clock for PDB moudle - * - *END**************************************************************************/ -void SIM_HAL_EnablePdbClock(SIM_Type* base, uint32_t instance) -{ - switch(instance) - { - case 0: - SIM_BWR_SCGC6_PDB0(base, 1); - break; - case 1: - SIM_BWR_SCGC6_PDB1(base, 1); - break; - default: break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisablePdbClock - * Description : Disable the clock for PDB module - * This function disables the clock for PDB moudle - * - *END**************************************************************************/ -void SIM_HAL_DisablePdbClock(SIM_Type* base, uint32_t instance) -{ - switch(instance) - { - case 0: - SIM_BWR_SCGC6_PDB0(base, 0); - break; - case 1: - SIM_BWR_SCGC6_PDB1(base, 0); - break; - default: break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetPdbGateCmd - * Description : Get the the clock gate state for PDB module - * This function will get the clock gate state for PDB moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetPdbGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch(instance) - { - case 0: - retValue = SIM_BRD_SCGC6_PDB0(base); - break; - case 1: - retValue = SIM_BRD_SCGC6_PDB1(base); - break; - default: break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableFtmClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC6_FTM0(base, 1); - break; - case 1: - SIM_BWR_SCGC6_FTM1(base, 1); - break; - case 3: - SIM_BWR_SCGC6_FTM3(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableFtmClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC6_FTM0(base, 0); - break; - case 1: - SIM_BWR_SCGC6_FTM1(base, 0); - break; - case 3: - SIM_BWR_SCGC6_FTM3(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetFtmGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_SCGC6_FTM0(base); - break; - case 1: - retValue = SIM_BRD_SCGC6_FTM1(base); - break; - case 2: - retValue = false; - break; - case 3: - retValue = SIM_BRD_SCGC6_FTM3(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcxMuxSelChannely - * Description : ADC x (0-A, 1-B)channel y (6,7) Mux. - * Refer to RM for specific channel settings - * Selects ADCx MUX0's channel to ADCx channel y. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcxMuxSelChannely(SIM_Type* base, uint32_t instance, - uint8_t channel, uint8_t select) -{ - assert (instance<2); - assert (channel<8); - assert (channel>5); - switch(instance) - { - case 0: - switch(channel) - { - case 6: - SIM_BWR_ADCOPT_ADCACH6SEL(base, select); - break; - case 7: - SIM_BWR_ADCOPT_ADCACH7SEL(base, select); - break; - default: - break; - } - break; - case 1: - switch(channel) - { - case 6: - SIM_BWR_ADCOPT_ADCBCH6SEL(base, select); - break; - case 7: - SIM_BWR_ADCOPT_ADCBCH7SEL(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChOutSrcMode - * Description : Get FlexTimer x channel y output source select setting - * This function will get FlexTimer x channel y output source select - * setting. - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetAdcxMuxSelChannely(SIM_Type* base, uint32_t instance, uint8_t channel) -{ - assert (instance<2); - assert (channel<8); - assert (channel>5); - uint8_t retValue = (uint8_t) false; - switch(instance) - { - case 0: - switch(channel) - { - case 6: - retValue = (uint8_t)SIM_BRD_ADCOPT_ADCACH6SEL(base); - break; - case 7: - retValue = (uint8_t)SIM_BRD_ADCOPT_ADCACH7SEL(base); - break; - default: - retValue = (uint8_t) false; - break; - } - break; - case 3: - switch(channel) - { - case 6: - retValue = (uint8_t)SIM_BRD_ADCOPT_ADCBCH6SEL(base); - break; - case 7: - retValue = (uint8_t)SIM_BRD_ADCOPT_ADCBCH7SEL(base); - break; - default: - retValue = (uint8_t) false; - break; - } - break; - default: - retValue = (uint8_t) false; - break; - } - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetNanoedgeRegulator12SupStdbyControl - * Description : Nanoedge Regulator 1.2 V Supply Standby Control - * This function controls the standby mode of the 1.2 V supply from the nanoedge voltage regulator. - * 00 Nanoedge regulator 1.2 V supply placed in normal mode - * 01 Nanoedge regulator 1.2 V supply placed in standby mode. - * 10 Nanoedge regulator 1.2 V supply placed in normal mode and SR12STDBY is write protected until - * chip reset. - * 11 Nanoedge regulator 1.2 V supply placed in standby mode and SR12STDBY is write protected until - * chip reset. - * - *END**************************************************************************/ -void SIM_HAL_SetNanoedgeRegulator12SupStdbyControl(SIM_Type* base, uint8_t select) -{ - assert (select < 4); - SIM_BWR_PWRC_SR12STDBY(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetNanoedgeRegulator12SupStdbyControl - * Description : Get Nanoedge Regulator 1.2 V Supply Standby Control - * This function will get the standby mode of the 1.2 V supply from the nanoedge voltage regulator - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetNanoedgeRegulator12SupStdbyControl(SIM_Type* base) -{ - return (uint8_t)SIM_BRD_PWRC_SR12STDBY(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetNanoedgeRegulator27SupStdbyControl - * Description : Nanoedge Regulator 2.7 V Supply Standby Control - * This function controls the standby mode of the 2.7 V supply from the nanoedge voltage regulator. - * 00 Nanoedge regulator 2.7 V supply placed in normal mode - * 01 Nanoedge regulator 2.7 V supply placed in standby mode. - * 10 Nanoedge regulator 2.7 V supply placed in normal mode and SR27STDBY is write protected until - * chip reset. - * 11 Nanoedge regulator 2.7 V supply placed in standby mode and SR27STDBY is write protected until - * chip reset. - * - *END**************************************************************************/ -void SIM_HAL_SetNanoedgeRegulator27SupStdbyControl(SIM_Type* base, uint8_t select) -{ - assert (select < 4); - SIM_BWR_PWRC_SR12STDBY(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetNanoedgeRegulator27SupStdbyControl - * Description : Get Nanoedge Regulator 2.7 V Supply Standby Control - * This function will get the standby mode of the 2.7 V supply from the nanoedge voltage regulator - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetNanoedgeRegulator27SupStdbyControl(SIM_Type* base) -{ - return (uint8_t)SIM_BRD_PWRC_SR12STDBY(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetNanoedgeReg27n12SupPwrdwnControl - * Description : Nanoedge Regulator 2.7V and 1.2V Supply Powerdown Control - * This function controls the powerdown mode of the 2.7V and 1.2V supply from the nanoedge voltage regulator - * 00 Nanoedge regulator placed in normal mode. - * 01 Nanoedge regulator placed in powerdown mode. - * 10 Nanoedge regulator placed in normal mode and SRPDN is write protected until chip reset. - * 11 Nanoedge regulator placed in powerdown mode and SRPDN is write protected until chip reset. - * - *END**************************************************************************/ -void SIM_HAL_SetNanoedgeReg27n12SupPwrdwnControl(SIM_Type* base, uint8_t select) -{ - assert (select < 4); - SIM_BWR_PWRC_SRPDN(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetNanoedgeReg27n12SupPwrdwnControl - * Description : Get Nanoedge Regulator 2.7 V Supply Standby Control - * This function will get the standby mode of the 2.7 V supply from the nanoedge voltage regulator - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetNanoedgeReg27n12SupPwrdwnControl(SIM_Type* base) -{ - return (uint8_t)SIM_BRD_PWRC_SRPDN(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetWdogClkSrc - * Description : WDOG Clock Select - * This function selects the clock source of the WDOG2008 watchdog. - * 0 Internal 1 kHz clock is source to WDOG2008 - * 1 MCGIRCLK is source to WDOG2008 - * - *END**************************************************************************/ -void SIM_HAL_SetWdogClkSrc(SIM_Type* base, bool select) -{ - SIM_BWR_WDOGC_WDOGCLKS(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetWdogClkSrc - * Description : Get WDOG Clock setting - * This function will get the clock source of the WDOG2008 watchdog - * - *END**************************************************************************/ -bool SIM_HAL_GetWdogClkSrc(SIM_Type* base) -{ - return (bool)SIM_BRD_WDOGC_WDOGCLKS(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarAPittrigX - * Description : Synchronize XBARA's Input PIT Trigger X with fast clock - * This function controls the synchronizer between PIT trigger X and XBARA's input. - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarAPittrigX(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG0(base, 1); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG1(base, 1); - break; - case 2: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG2(base, 1); - break; - case 3: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG3(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarAPittrigX - * Description : Disable the synchronizer between PIT trigger X and XBARA's input - * This function Disables the synchronizer between PIT trigger X and XBARA's input - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarAPittrigX(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG0(base, 0); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG1(base, 0); - break; - case 2: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG2(base, 0); - break; - case 3: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG3(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarAPittrigXcmd - * Description : Get the synchronizer cmd between PIT trigger X and XBARA's input - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarAPittrigXcmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_MISCTRL2_SYNCXBARAPITTRIG0(base); - break; - case 1: - retValue = SIM_BRD_MISCTRL2_SYNCXBARAPITTRIG1(base); - break; - case 2: - retValue = SIM_BRD_MISCTRL2_SYNCXBARAPITTRIG2(base); - break; - case 3: - retValue = SIM_BRD_MISCTRL2_SYNCXBARAPITTRIG3(base); - break; - default: - retValue = false; - break; - } - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarBPittrigX - * Description : Synchronize XBARB's Input PIT Trigger X with fast clock - * This function controls the synchronizer between PIT trigger X and XBARB's input. - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarBPittrigX(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCXBARBPITTRIG0(base, 1); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCXBARBPITTRIG1(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarBPittrigX - * Description : Disable the synchronizer between PIT trigger X and XBARB's input - * This function Disables the synchronizer between PIT trigger X and XBARB's input - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarBPittrigX(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCXBARBPITTRIG0(base, 0); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCXBARBPITTRIG1(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarBPittrigXcmd - * Description : Get the synchronizer cmd between PIT trigger X and XBARB's input - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarBPittrigXcmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_MISCTRL2_SYNCXBARBPITTRIG0(base); - break; - case 1: - retValue = SIM_BRD_MISCTRL2_SYNCXBARBPITTRIG1(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarDac - * Description : Synchronize XBARA's output for DAC Hardware Trigger with flash/slow clock - * This function controls the synchronizer between XBARA's output and DAC hardware trigger. - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarDac(SIM_Type* base) -{ - SIM_BWR_MISCTRL2_SYNCDACHWTRIG(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarDac - * Description : Disable the synchronizer between XBARA's output and DAC hardware trigger - * This function Disables the synchronizer between XBARA's output and DAC hardware trigger - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarDac(SIM_Type* base) -{ - SIM_BWR_MISCTRL2_SYNCDACHWTRIG(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarDaccmd - * Description : Get the synchronizer cmd between XBARA's output and DAC hardware trigger - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarDaccmd(SIM_Type* base) -{ - return (bool)SIM_BRD_MISCTRL2_SYNCDACHWTRIG(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarEwmin - * Description : Enable the synchronizer between XBARA's output and EWM's ewm_in - * This function enables the synchronizer between XBARA's output and EWM's ewm_in - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarEwmin(SIM_Type* base) -{ - SIM_BWR_MISCTRL2_SYNCEWMIN(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarEwmin - * Description : Disable the synchronizer between XBARA's output and EWM's ewm_in - * This function Disables the synchronizer between XBARA's output and EWM's ewm_in - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarEwmin(SIM_Type* base) -{ - SIM_BWR_MISCTRL2_SYNCEWMIN(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarEwmincmd - * Description : Get the synchronizer cmd between XBARA's output and EWM's ewm_in - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarEwmincmd(SIM_Type* base) -{ - return (bool)SIM_BRD_MISCTRL2_SYNCEWMIN(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarCmpX - * Description : Enable the the synchronizer between XBARA's output and CMP3's sample/window input - * This function enables the the synchronizer between XBARA's output and CMP3's sample/window input - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarCmpX(SIM_Type* base, uint32_t instance) -{ - assert (instance < CMP_INSTANCE_COUNT); - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCCMP0SAMPLEWIN(base, 1); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCCMP1SAMPLEWIN(base, 1); - break; - case 2: - SIM_BWR_MISCTRL2_SYNCCMP2SAMPLEWIN(base, 1); - break; - case 3: - SIM_BWR_MISCTRL2_SYNCCMP3SAMPLEWIN(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarCmpX - * Description : Disable the synchronizer between XBARA's output and CMP3's sample/window input - * This function Disables the synchronizer between XBARA's output and CMP3's sample/window input - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarCmpX(SIM_Type* base, uint32_t instance) -{ - assert (instance < CMP_INSTANCE_COUNT); - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCCMP0SAMPLEWIN(base, 0); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCCMP1SAMPLEWIN(base, 0); - break; - case 2: - SIM_BWR_MISCTRL2_SYNCCMP2SAMPLEWIN(base, 0); - break; - case 3: - SIM_BWR_MISCTRL2_SYNCCMP3SAMPLEWIN(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarCmpXcmd - * Description : Get the synchronizer cmd between XBARA's output and CMP3's sample/window input - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarCmpXcmd(SIM_Type* base, uint32_t instance) -{ - assert (instance < CMP_INSTANCE_COUNT); - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_MISCTRL2_SYNCCMP0SAMPLEWIN(base); - break; - case 1: - retValue = SIM_BRD_MISCTRL2_SYNCCMP1SAMPLEWIN(base); - break; - case 2: - retValue = SIM_BRD_MISCTRL2_SYNCCMP2SAMPLEWIN(base); - break; - case 3: - retValue = SIM_BRD_MISCTRL2_SYNCCMP3SAMPLEWIN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetCmpWinxSrc - * Description : Set CMP Sample/Window Input X Source - * This function controls the sample/window source of CMP module - * - *END**************************************************************************/ -void SIM_HAL_SetCmpWinxSrc(SIM_Type* base, uint32_t instance, - sim_cmp_win_in_src select) -{ - assert (instance < CMP_INSTANCE_COUNT); - switch (instance) - { - case 0: - SIM_BWR_MISCTRL_CMPWIN0SRC(base, select); - break; - case 1: - SIM_BWR_MISCTRL_CMPWIN1SRC(base, select); - break; - case 2: - SIM_BWR_MISCTRL_CMPWIN2SRC(base, select); - break; - case 3: - SIM_BWR_MISCTRL_CMPWIN3SRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetCmpWinxSrc - * Description : Get CMP Sample/Window Input X Source - * This function will get the sample/window source of CMP module - * - *END**************************************************************************/ -sim_cmp_win_in_src SIM_HAL_GetCmpWinxSrc(SIM_Type* base, uint32_t instance) -{ - assert (instance < CMP_INSTANCE_COUNT); - sim_cmp_win_in_src retValue = (sim_cmp_win_in_src)0; - switch (instance) - { - case 0: - retValue = (sim_cmp_win_in_src)SIM_BRD_MISCTRL_CMPWIN0SRC(base); - break; - case 1: - retValue = (sim_cmp_win_in_src)SIM_BRD_MISCTRL_CMPWIN1SRC(base); - break; - case 2: - retValue = (sim_cmp_win_in_src)SIM_BRD_MISCTRL_CMPWIN2SRC(base); - break; - case 3: - retValue = (sim_cmp_win_in_src)SIM_BRD_MISCTRL_CMPWIN3SRC(base); - break; - default: - break; - } - - return retValue; -} - - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetEwmInSrc - * Description : Set EWM_IN source setting - * This function controls the ewm_in source of EWM module - * - *END**************************************************************************/ -void SIM_HAL_SetEwmInSrc(SIM_Type* base, sim_ewm_in_src select) -{ - SIM_BWR_MISCTRL_EWMINSRC(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetEwmInSrc - * Description : Get EWM_IN source setting - * This function will get the ewm_in source of EWM module - * - *END**************************************************************************/ -sim_ewm_in_src SIM_HAL_GetEwmInSrc(SIM_Type* base) -{ - return (sim_ewm_in_src)SIM_BRD_MISCTRL_EWMINSRC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetDacHwTrigSrc - * Description : Set DAC x Hardware trigger source setting - * This function will select the DAC0 Hardware Trigger Input Source - * - *END**************************************************************************/ -void SIM_HAL_SetDacHwTrigSrc(SIM_Type* base,sim_dac_hw_trg_sel select) -{ - SIM_BWR_MISCTRL_DACTRIGSRC(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetDacHwTrigSrc - * Description : Get DAC x Hardware trigger source setting - * This function will get the DAC0 Hardware Trigger Input Source - * - *END**************************************************************************/ -sim_dac_hw_trg_sel SIM_HAL_GetDacHwTrigSrc(SIM_Type* base, uint32_t instance) -{ - return (sim_dac_hw_trg_sel)SIM_BRD_MISCTRL_DACTRIGSRC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance) -{ - return (sim_ftm_clk_sel_t)0; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel) -{ - return (sim_ftm_ch_src_t)0; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChOutSrcMode - * Description : FlexTimer x channel y output source select setting. - * This function will select FlexTimer x channel y output source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChOutSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_out_src_t select) -{ - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChOutSrcMode - * Description : Get FlexTimer x channel y output source select setting - * This function will get FlexTimer x channel y output source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_out_src_t SIM_HAL_GetFtmChOutSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel) -{ - return (sim_ftm_ch_out_src_t)0; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmCarrierFreqCmd - * Description : Set FTMxCFSELBIT - * This function sets FlexTimer x carrier frequency selection software configuration setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmCarrierFreqCmd(SIM_Type* base, uint32_t instance, bool ftmcarrierfreqsrc) -{ - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmCarrierFreqCmd - * Description : Get FlexTimer x carrier frequency selection software configuration setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetFtmCarrierFreqCmd(SIM_Type* base, uint32_t instance) -{ - return true; -} -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmSyncCmd - * Description : Set FTMxSYNCBIT - * This function sets FlexTimer x hardware trigger 0 software synchronization. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmSyncCmd(SIM_Type* base, uint32_t instance, bool sync) -{ - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type* base, - sim_cadc_conv_id_t convId, - sim_adc_alt_trg_en enable) -{ - switch (convId) - { - case kSimCAdcConvA: - SIM_BWR_SOPT7_ADCAALTTRGEN(base, enable); - break; - case kSimCAdcConvB: - SIM_BWR_SOPT7_ADCBALTTRGEN(base, enable); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -sim_adc_alt_trg_en SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type* base, sim_cadc_conv_id_t convId) -{ - sim_adc_alt_trg_en retValue = (sim_adc_alt_trg_en)false; - - switch (convId) - { - case kSimCAdcConvA: - retValue = (sim_adc_alt_trg_en)SIM_BRD_SOPT7_ADCAALTTRGEN(base); - break; - case kSimCAdcConvB: - retValue = (sim_adc_alt_trg_en)SIM_BRD_SOPT7_ADCBALTTRGEN(base); - break; - default: - retValue = (sim_adc_alt_trg_en)false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type* base, - sim_cadc_conv_id_t convId, - sim_adc_trg_sel_t select) -{ - switch (convId) - { - case kSimCAdcConvA: - SIM_BWR_SOPT7_ADCATRGSEL(base, select); - break; - case kSimCAdcConvB: - SIM_BWR_SOPT7_ADCBTRGSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type* base, sim_cadc_conv_id_t convId) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - switch (convId) - { - case kSimCAdcConvA: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADCATRGSEL(base); - break; - case kSimCAdcConvB: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADCBTRGSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type* base, - sim_cadc_conv_id_t convId, - bool altTrigEn, - sim_adc_trg_sel_t trigSel) -{ - switch (convId) - { - case kSimCAdcConvA: - SIM_BWR_SOPT7_ADCAALTTRGEN(base, altTrigEn ? 1 : 0); - break; - case kSimCAdcConvB: - SIM_BWR_SOPT7_ADCBALTTRGEN(base, altTrigEn ? 1 : 0); - break; - default: - break; - } - - if (altTrigEn) - { - switch (convId) - { - case kSimCAdcConvA: - SIM_BWR_SOPT7_ADCATRGSEL(base, trigSel); - break; - case kSimCAdcConvB: - SIM_BWR_SOPT7_ADCBTRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type* base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type* base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type* base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type* base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t trigger) -{ - return (sim_ftm_trg_src_t)0; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type* base, - uint8_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type* base, - uint8_t instance, - uint8_t fault) -{ - return (sim_ftm_flt_sel_t)0; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnablePitClock - * Description : Enable the clock for PIT module - * This function enables the clock for PIT moudle - * - *END**************************************************************************/ -void SIM_HAL_EnablePitClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_PIT(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisablePitClock - * Description : Disable the clock for PIT module - * This function disables the clock for PIT moudle - * - *END**************************************************************************/ -void SIM_HAL_DisablePitClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_PIT(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetPitGateCmd - * Description : Get the the clock gate state for PIT module - * This function will get the clock gate state for PIT moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetPitGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC6_PIT(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableLptmrClock - * Description : Enable the clock for LPTIMER module - * This function enables the clock for LPTIMER moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableLptmrClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC5_LPTMR(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableLptmrClock - * Description : Disable the clock for LPTIMER module - * This function disables the clock for LPTIMER moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableLptmrClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC5_LPTMR(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetLptmrGateCmd - * Description : Get the the clock gate state for LPTIMER module - * This function will get the clock gate state for LPTIMER moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetLptmrGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC5_LPTMR(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableFlexcanClock - * Description : Enable the clock for FLEXCAN module - * This function enables the clock for FLEXCAN moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableFlexcanClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC6_FLEXCAN0(base, 1); - break; - case 1: - SIM_BWR_SCGC6_FLEXCAN1(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableFlexcanClock - * Description : Disable the clock for FLEXCAN module - * This function disables the clock for FLEXCAN moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableFlexcanClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC6_FLEXCAN0(base, 0); - break; - case 1: - SIM_BWR_SCGC6_FLEXCAN1(base, 0); - break; - default: - break; - } - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFlexcanGateCmd - * Description : Get the the clock gate state for FLEXCAN module - * This function will get the clock gate state for FLEXCAN moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetFlexcanGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_SCGC6_FLEXCAN0(base); - break; - case 1: - retValue = SIM_BRD_SCGC6_FLEXCAN1(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableSpiClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC6_SPI0(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableSpiClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC6_SPI0(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetSpiGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_SCGC6_SPI0(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableI2cClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC4_I2C0(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableI2cClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC4_I2C0(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetI2cGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_SCGC4_I2C0(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableUartClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC4_UART0(base, 1); - break; - case 1: - SIM_BWR_SCGC4_UART1(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function disables the clock for UART moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableUartClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC4_UART0(base, 0); - break; - case 1: - SIM_BWR_SCGC4_UART1(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetUartGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_SCGC4_UART0(base); - break; - case 1: - retValue = SIM_BRD_SCGC4_UART1(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnablePwmClock - * Description : Enable the clock for eFlexPWM module - * This function enables the clock for eFlexPWM moudle - * - *END**************************************************************************/ -void SIM_HAL_EnablePwmClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC4_eFlexPWM0(base, 1); - break; - case 1: - SIM_BWR_SCGC4_eFlexPWM1(base, 1); - break; - case 2: - SIM_BWR_SCGC4_eFlexPWM2(base, 1); - break; - case 3: - SIM_BWR_SCGC4_eFlexPWM3(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisablePwmClock - * Description : Disable the clock for eFlexPWM module - * This function disables the clock for eFlexPWM moudle - * - *END**************************************************************************/ -void SIM_HAL_DisablePwmClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC4_eFlexPWM0(base, 0); - break; - case 1: - SIM_BWR_SCGC4_eFlexPWM1(base, 0); - break; - case 2: - SIM_BWR_SCGC4_eFlexPWM2(base, 0); - break; - case 3: - SIM_BWR_SCGC4_eFlexPWM3(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetPwmGateCmd - * Description : Get the the clock gate state for eFlexPWM module - * This function will get the clock gate state for eFlexPWM moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetPwmGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_SCGC4_eFlexPWM0(base); - break; - case 1: - retValue = SIM_BRD_SCGC4_eFlexPWM1(base); - break; - case 2: - retValue = SIM_BRD_SCGC4_eFlexPWM2(base); - break; - case 3: - retValue = SIM_BRD_SCGC4_eFlexPWM3(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableAoiClock - * Description : Enable the clock for AOI module - * This function enables the clock for AOI moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableAoiClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC5_AOI(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableAoiClock - * Description : Disable the clock for AOI module - * This function disables the clock for AOI moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableAoiClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC5_AOI(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAoiGateCmd - * Description : Get the the clock gate state for AOI module - * This function will get the clock gate state for AOI moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetAoiGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC5_AOI(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableXbarClock - * Description : Enable the clock for XBAR module - * This function enables the clock for XBAR moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableXbarClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC5_XBARA(base, 1); - break; - case 1: - SIM_BWR_SCGC5_XBARB(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableXbarClock - * Description : Disable the clock for XBAR module - * This function disables the clock for XBAR moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableXbarClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC5_XBARA(base, 0); - break; - case 1: - SIM_BWR_SCGC5_XBARB(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetXbarGateCmd - * Description : Get the the clock gate state for XBAR module - * This function will get the clock gate state for XBAR moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetXbarGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_SCGC5_XBARA(base); - break; - case 1: - retValue = SIM_BRD_SCGC5_XBARB(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableEncClock - * Description : Enable the clock for ENC module - * This function enables the clock for ENC moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableEncClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC5_ENC(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableEncClock - * Description : Disable the clock for ENC module - * This function disables the clock for ENC moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableEncClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC5_ENC(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetEncGateCmd - * Description : Get the the clock gate state for ENC module - * This function will get the clock gate state for ENC moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetEncGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC5_ENC(base); -} -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKV44F15/fsl_sim_hal_MKV44F15.h b/KSDK_1.2.0/platform/hal/src/sim/MKV44F15/fsl_sim_hal_MKV44F15.h deleted file mode 100644 index f24da85..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKV44F15/fsl_sim_hal_MKV44F15.h +++ /dev/null @@ -1,3018 +0,0 @@ -/* - * Copyright (c) 2014 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_KV44F15_H__) -#define __FSL_SIM_HAL_KV44F15_H__ - -/*! @addtogroup sim_hal*/ -/*! @{*/ -#include "fsl_sim_hal.h" -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/*! @brief WDOG clock source select */ -typedef enum _clock_wdog_src_t -{ - kClockWdogSrcLpoClk, /*!< LPO */ - kClockWdogSrcAltClk, /*!< Alternative clock, for K64F12 it is Bus clock. */ -} clock_wdog_src_t; - -/*! @brief Debug trace clock source select */ -typedef enum _clock_trace_src_t -{ - kClockTraceSrcMcgoutClk, /*!< MCG out clock */ - kClockTraceSrcCoreClk, /*!< core clock */ -} clock_trace_src_t; - -/*! @brief Debug trace clock source select */ -typedef enum _clock_nanoedge_clk2x_src -{ - kClockNanoedgeSrcMcgPllClk, /*!< MCG out clock */ - kClockNanoedgeSrcMcgPllClk2x, /*!< core clock */ -} clock_nanoedge_clk2x_src; - -/*! @brief SIM OSC32KSEL clock source select */ -typedef enum _sim_osc32k_clock_sel -{ - kSimOsc32kSelOsc32k, /* OSC 32k clock */ - kSimOsc32kSelReserved, /* Reserved */ - kSimOsc32kSelReserved1, /* Reserved */ - kSimOsc32kSelLpo /* LPO clock */ -} sim_osc32k_clock_sel_t; - -/*! @brief SIM NANOEDGECLK2XSEL clock source select */ -typedef enum _sim_nanoedge_clock_sel -{ - kSimNanoEdgeMcgPllClk, /* MCG PLL clock */ - kSimNanoEdgeMcgPll2xClk, /* MCG PLL 2X clock */ -} sim_nanoedge_clock_sel_t; - -/*! @brief SIM TRACECLKSEL clock source select */ -typedef enum _sim_trace_clock_sel -{ - kSimTraceMcgoutClk, /* MCG out clock */ - kSimTraceCoreClk /* core clock */ -} sim_trace_clock_sel_t; - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _sim_clkout_clock_sel -{ - kSimClkoutReserved, /* Reserved */ - kSimClkoutReserved1, /* Reserved */ - kSimClkoutFlashClk, /* Flash clock */ - kSimClkoutLpoClk, /* LPO clock */ - kSimClkoutMcgIrcClk, /* MCG out clock */ - kSimClkoutOscErcClkUndiv, /* Undivided OSC ERC clock */ - kSimClkoutOscErcClk /* OSC ERC clock */ - -} sim_clkout_clock_sel_t; - -/*! @brief SIM ADCB trigger select */ -typedef enum _sim_adcb_trg_sel -{ - kSimAdcbTrgSelHighSpeedComp0 = 1U, /* High speed comparator 0 output */ - kSimAdcbTrgSelHighSpeedComp1 = 2U, /* High speed comparator 1 output */ - kSimAdcbTrgSelHighSpeedComp2 = 3U, /* High speed comparator 2 output */ - kSimAdcbTrgSelPit0 = 4U, /* PIT trigger 0 */ - kSimAdcbTrgSelPit1 = 5U, /* PIT trigger 1 */ - kSimAdcbTrgSelPit2 = 6U, /* PIT trigger 2 */ - kSimAdcbTrgSelPit3 = 7U, /* PIT trigger 3 */ - kSimAdcbTrgSelFtm0 = 8U, /* FTM0 trigger */ - kSimAdcbTrgSelFtm1 = 9U, /* FTM1 trigger */ - kSimAdcbTrgSelFtm3 = 11U, /* FTM3 trigger */ - kSimAdcbTrgSelxbaraout41 = 12U, /* XBARAOUT41 */ - kSimAdcbTrgSelLptimer = 14U, /* Low-power timer trigger */ -} sim_adcb_trg_sel_t; - -/*! @brief SIM ADC trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselPdb0Ext = 0U, /* PDB0_EXTRG for ADCA, Reserved for ADCB */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /* High speed comparator 0 output */ - kSimAdcTrgSelHighSpeedComp1 = 2U, /* High speed comparator 1 output */ - kSimAdcTrgSelHighSpeedComp2 = 3U, /* High speed comparator 2 output */ - kSimAdcTrgSelPit0 = 4U, /* PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /* PIT trigger 1 */ - kSimAdcTrgSelPit2 = 6U, /* PIT trigger 2 */ - kSimAdcTrgSelPit3 = 7U, /* PIT trigger 3 */ - kSimAdcTrgSelFtm0 = 8U, /* FTM0 trigger */ - kSimAdcTrgSelFtm1 = 9U, /* FTM1 trigger */ - kSimAdcTrgSelFtm3 = 11U, /* FTM3 trigger */ - kSimAdcTrgSelxbaraout = 12U, /* XBARAOUT38 for ADCA & XBAROUT41 for ADCB */ - kSimAdcTrgSelLptimer = 14U, /* Low-power timer trigger */ -} sim_adc_trg_sel_t; - -/*! - * @brief Defines the type of enumerating ADC converter's ID. - */ -typedef enum _sim_cadc_conv_id -{ - kSimCAdcConvA = 0U,/*!< ID for ADC converter A. */ - kSimCAdcConvB = 1U /*!< ID for ADC converter B. */ -} sim_cadc_conv_id_t; - -/*! @brief SIM ADC alternate trigger enable */ -typedef enum _sim_adc_alt_trg_en -{ - kSimAdcTrgenXbarout = 0U, /* XBARAOUT12 for ADCA, XBARAOUT13 for ADCB */ - kSimAdcTrgenPdb = 1U, /* PDB0 for ADCA, PDB1 for ADCB */ - kSimAdcTrgenalt0 = 2U, /* alternate trigger enable */ - kSimAdcTrgenalt1 = 3U, /* High speed comparator 2 output */ -} sim_adc_alt_trg_en; - -/*! @brief DAC0 Hardware Trigger Input Source */ -typedef enum _sim_dac_hw_trg_sel -{ - kSimDacHwTrgSelXbarout15 = 0U, /* XBARA output 15 */ - kSimDacHwTrgSelPdb01Int = 1U, /* both PDB0 interval trigger 0 and PDB1 interval trigger 0 */ - kSimDacHwTrgSelPdb0Int = 2U, /* PDB0 interval trigger 0 */ - kSimDacHwTrgSelPdb1Int = 3U, /* PDB1 interval trigger 0 */ -} sim_dac_hw_trg_sel; - -/*! @brief the ewm_in source of EWM module. */ -typedef enum _sim_ewm_in_src -{ - kSimDacHwTrgSelXbarout58 = 0U, /* XBARA output 58 */ - kSimDacHwTrgSelEwnInPin = 1U, /* EWM_IN Pin */ -} sim_ewm_in_src; - -/*! @brief CMP Sample/Window Input X Source*/ -typedef enum _sim_cmp_win_in_src -{ - kSimCmpWinInSrcXbarout = 0U, /* XBARA output - Refer RM for specific module */ - kSimCmpWinInSrcPdb01Int = 1U, /* CMP0 Sample/Window input driven by both PDB0 and PDB1 pluse-out channel 0 */ - kSimCmpWinInSrcPdb0Int = 2U, /* PDB0 interval trigger 0 */ - kSimCmpWinInSrcPdb1Int = 3U, /* PDB1 interval trigger 0 */ -} sim_cmp_win_in_src; - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCGIRCLK */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClkUndiv, /*!< OSCERCLK_UNDIV clock */ -} clock_lptmr_src_t; - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcLpo = 3U, /*!< LPO clock. */ -} clock_er32k_src_t; - -/*! @brief FLEXCAN clock source select */ -typedef enum _clock_flexcan_src_t -{ - kClockFlexcanSrcOsc0erClk, /*!< OSCERCLK */ - kClockFlexcanSrcBusClk /*!< Bus clock */ -} clock_flexcan_src_t; - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateEwm0 = FSL_SIM_SCGC_BIT(4U, 1U), - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateUart0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateCmp = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGatePwm0 = FSL_SIM_SCGC_BIT(4U, 24U), - kSimClockGatePwm1 = FSL_SIM_SCGC_BIT(4U, 25U), - kSimClockGatePwm2 = FSL_SIM_SCGC_BIT(4U, 26U), - kSimClockGatePwm3 = FSL_SIM_SCGC_BIT(4U, 27U), - - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - kSimClockGateEnc0 = FSL_SIM_SCGC_BIT(5U, 21U), - kSimClockGateXbarA = FSL_SIM_SCGC_BIT(5U, 25U), - kSimClockGateXbarB = FSL_SIM_SCGC_BIT(5U, 26U), - kSimClockGateAoi0 = FSL_SIM_SCGC_BIT(5U, 27U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(5U, 28U), - - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateFlexcan0 = FSL_SIM_SCGC_BIT(6U, 4U), - kSimClockGateFlexcan1 = FSL_SIM_SCGC_BIT(6U, 5U), - kSimClockGateFtm3 = FSL_SIM_SCGC_BIT(6U, 6U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(6U, 12U), - kSimClockGatePdb1 = FSL_SIM_SCGC_BIT(6U, 17U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), - kSimClockGatePdb0 = FSL_SIM_SCGC_BIT(6U, 22U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateFtm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateFtm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(6U, 31U), - - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 8U), -} sim_clock_gate_name_t; - -/*! @brief Clock source and sel names */ -typedef enum _clock_source_names { - kClockNfcSrc, /* NFCSRC*/ - kClockEsdhcSrc, /* ESDHCSRC K70*/ - kClockSdhcSrc, /* SDHCSRC K64*/ - kClockLcdcSrc, /* LCDCSRC*/ - kClockTimeSrc, /* TIMESRC*/ - kClockRmiiSrc, /* RMIISRC*/ - kClockUsbfSrc, /* USBFSRC K70*/ - kClockUsbSrc, /* USBSRC K64, KL25, KV31, and K22*/ - kClockUsbhSrc, /* USBHSRC*/ - kClockUart0Src, /* UART0SRC*/ - kClockLpuartSrc, /* LPUARTSRC K22, KV31 */ - kClockTpmSrc, /* TPMSRC*/ - kClockOsc32kSel, /* OSC32KSEL*/ - kClockUsbfSel, /* USBF_CLKSEL*/ - kClockPllfllSel, /* PLLFLLSEL*/ - kClockNfcSel, /* NFC_CLKSEL*/ - kClockLcdcSel, /* LCDC_CLKSEL*/ - kClockTraceSel, /* TRACE_CLKSEL*/ - kClockClkoutSel, /* CLKOUTSEL*/ - kClockRtcClkoutSel, /* RTCCLKOUTSEL */ - kClockNanoEdgeClk2xSel, /* NANOEDGECLK2XSEL */ - kClockSourceMax -} clock_source_names_t; - -/*! @brief Clock Divider names*/ -typedef enum _clock_divider_names { - kClockDividerOutdiv1, /* OUTDIV1*/ - kClockDividerOutdiv2, /* OUTDIV2*/ - kClockDividerOutdiv3, /* OUTDIV3*/ - kClockDividerOutdiv4, /* OUTDIV4*/ - kClockDividerUsbFrac, /* (USBFRAC + 1) / (USBDIV + 1)*/ - kClockDividerUsbDiv, - kClockDividerUsbfsFrac, /* (USBFSFRAC + 1) / (USBFSDIV) + 1)*/ - kClockDividerUsbfsDiv, - kClockDividerUsbhsFrac, /* (USBHSFRAC + 1) / (USBHSDIV + 1)*/ - kClockDividerUsbhsDiv, - kClockDividerLcdcFrac, /* (LCDCFRAC + 1) / (LCDCDIV + 1)*/ - kClockDividerLcdcDiv, - kClockDividerNfcFrac, /* (NFCFRAC + 1) / (NFCDIV + 1)*/ - kClockDividerNfcDiv, - kClockDividerSpecial1, /* special divider 1*/ - kClockDividerMax -} clock_divider_names_t; - - - -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_stop -{ - kSimUsbsstbyNoRegulator, /* regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /* regulator in standby during Stop modes */ -} sim_usbsstby_stop_t; - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_stop -{ - kSimUsbvstbyNoRegulator, /* regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /* regulator in standby during VLPR and VLPW modes */ -} sim_usbvstby_stop_t; - -/*! @brief SIM CMT/UART pad drive strength */ -typedef enum _sim_cmtuartpad_strengh -{ - kSimCmtuartSinglePad, /* Single-pad drive strength for CMT IRO or UART0_TXD */ - kSimCmtuartDualPad /* Dual-pad drive strength for CMT IRO or UART0_TXD */ -} sim_cmtuartpad_strengh_t; - -/*! @brief SIM PTD7 pad drive strength */ -typedef enum _sim_ptd7pad_strengh -{ - kSimPtd7padSinglePad, /* Single-pad drive strength for PTD7 */ - kSimPtd7padDualPad /* Dual-pad drive strength for PTD7 */ -} sim_ptd7pad_strengh_t; - -/*! @brief SIM FlexBus security level */ -typedef enum _sim_flexbus_security_level -{ - kSimFbslLevel0, /* All off-chip accesses (op code and data) via the FlexBus */ - /* and DDR controller are disallowed */ - kSimFbslLevel1, /* Undefined */ - kSimFbslLevel2, /* Off-chip op code accesses are disallowed. Data accesses */ - /* are allowed */ - kSimFbslLevel3 /* Off-chip op code accesses and data accesses are allowed */ -} sim_flexbus_security_level_t; - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /* UARTx_RX Pin */ - kSimUartRxsrcCmp0, /* CMP0 */ - kSimUartRxsrcCmp1, /* CMP1 */ - kSimUartRxsrcReserved /* Reserved */ -} sim_uart_rxsrc_t; - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /* UARTx_TX Pin */ - kSimUartTxsrcFtm1, /* UARTx_TX pin modulated with FTM1 channel 0 output */ -} sim_uart_txsrc_t; - -/*! @brief SIM FlexTimer x trigger y select */ -typedef enum _sim_ftm_trg_src -{ - kSimFtmTrgSrc0, /* FlexTimer x trigger y select 0 */ - kSimFtmTrgSrc1 /* FlexTimer x trigger y select 1 */ -} sim_ftm_trg_src_t; - -/*! @brief SIM FlexTimer external clock select */ -typedef enum _sim_ftm_clk_sel -{ - kSimFtmClkSel0, /* FTM CLKIN0 pin. */ - kSimFtmClkSel1, /* FTM CLKIN1 pin. */ - kSimFtmClkSel2 /* FTM CLKIN2 pin. */ -} sim_ftm_clk_sel_t; - -/*! @brief SIM FlexTimer x channel y input capture source select */ -typedef enum _sim_ftm_ch_src -{ - kSimFtmChSrc0, /* See RM for details of each selection for each channel */ - kSimFtmChSrc1, /* See RM for details of each selection for each channel */ - kSimFtmChSrc2, /* See RM for details of each selection for each channel */ - kSimFtmChSrc3 /* See RM for details of each selection for each channel */ -} sim_ftm_ch_src_t; - -/*! @brief SIM FlexTimer x channel y output source select */ -typedef enum _sim_ftm_ch_out_src -{ - kSimFtmChOutSrc0, - kSimFtmChOutSrc1, -} sim_ftm_ch_out_src_t; - -/*! @brief SIM FlexTimer x Fault y select */ -typedef enum _sim_ftm_flt_sel -{ - kSimFtmFltSel0, /* FlexTimer x fault y select 0 */ - kSimFtmFltSel1 /* FlexTimer x fault y select 1 */ -} sim_ftm_flt_sel_t; - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /* Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /* Timer/PWM TPM_CLKIN1 pin. */ -} sim_tpm_clk_sel_t; - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /* TPMx_CH0 signal */ - kSimTpmChSrc1 /* CMP0 output */ -} sim_tpm_ch_src_t; - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ -/*! - * @brief Sets the clock source setting. - * - * This function sets the settings for a specified clock source. Each clock - * source has its own clock selection settings. See the chip reference manual for - * clock source detailed settings and the clock_source_names_t - * for clock sources. - * - * @param base Base address for current SIM instance. - * @param clockSource Clock source name defined in sim_clock_source_names_t - * @param setting Setting value - * @return status If the clock source doesn't exist, it returns an error. - */ -sim_hal_status_t CLOCK_HAL_SetSource(SIM_Type* base, clock_source_names_t clockSource, uint8_t setting); - -/*! - * @brief Gets the clock source setting. - * - * This function gets the settings for a specified clock source. Each clock - * source has its own clock selection settings. See the reference manual for - * clock source detailed settings and the clock_source_names_t - * for clock sources. - * - * @param base Base address for current SIM instance. - * @param clockSource Clock source name - * @param setting Current setting for the clock source - * @return status If the clock source doesn't exist, it returns an error. - */ -sim_hal_status_t CLOCK_HAL_GetSource(SIM_Type* base, clock_source_names_t clockSource, - uint8_t *setting); - -/*! - * @brief Sets the clock divider setting. - * - * This function sets the setting for a specified clock divider. See the - * reference manual for a supported clock divider and value range and the - * clock_divider_names_t for dividers. - * - * @param base Base address for current SIM instance. - * @param clockDivider Clock divider name - * @param setting Divider setting - * @return status If the clock divider doesn't exist, it returns an error. - */ -sim_hal_status_t CLOCK_HAL_SetDivider(SIM_Type* base, clock_divider_names_t clockDivider, - uint32_t setting); - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * See the reference manual for a supported clock divider and value range and the - * clock_divider_names_t for clock out dividers. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type* base, uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type* base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -/*@}*/ - -/*! @name individual field access APIs*/ -/*@{*/ - -#if FSL_FEATURE_SIM_OPT_HAS_RAMSIZE -/*! - * @brief Gets RAM size. - * - * This function gets the RAM size. The field specifies the amount of system RAM - * available on the device. - * - * @param base Base address for current SIM instance. - * @return size RAM size on the device - */ -static inline uint32_t SIM_HAL_GetRamSize(SIM_Type* base) -{ - return SIM_BRD_SOPT1_RAMSIZE(base); -} -#endif /* FSL_FEATURE_SIM_OPT_HAS_RAMSIZE */ - -#if FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type* base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type* base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type* base, - sim_usbsstby_stop_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_stop_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type* base) -{ - return (sim_usbsstby_stop_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type* base, - sim_usbvstby_stop_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_stop_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type* base) -{ - return (sim_usbvstby_stop_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type* base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type* base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type* base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type* base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type* base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type* base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif - -#if FSL_FEATURE_SIM_OPT_HAS_CMTUARTPAD -/*! - * @brief Sets the CMT/UART pad drive strength setting. - * - * This function controls the output drive strength of the CMT IRO signal or - * UART0_TXD signal on PTD7 pin by selecting either one or two pads to drive it. - * - * @param base Base address for current SIM instance. - * @param setting CMT/UART pad drive strength setting - * - 0: Single-pad drive strength for CMT IRO or UART0_TXD. - * - 1: Dual-pad drive strength for CMT IRO or UART0_TXD. - */ -static inline void SIM_HAL_SetCmtUartPadDriveStrengthMode(SIM_Type* base, - sim_cmtuartpad_strengh_t setting) -{ - SIM_BWR_SOPT2_CMTUARTPAD(base, setting); -} - -/*! - * @brief Gets the CMT/UART pad drive strength setting. - * - * This function gets the CMT/UART pad drive strength setting. - * - * @param base Base address for current SIM instance. - * @return setting CMT/UART pad drive strength setting - */ -static inline sim_cmtuartpad_strengh_t SIM_HAL_GetCmtUartPadDriveStrengthMode(SIM_Type* base) -{ - return (sim_cmtuartpad_strengh_t)SIM_BRD_SOPT2_CMTUARTPAD(base); -} -#endif /* FSL_FEATURE_SIM_OPT_HAS_CMTUARTPAD */ - -#if FSL_FEATURE_SIM_OPT_HAS_PTD7PAD -/*! - * @brief Sets the PTD7 pad drive strength setting. - * - * This function controls the output drive strength of the PTD7 pin by selecting - * either one or two pads to drive it. - * - * @param base Base address for current SIM instance. - * @param setting PTD7 pad drive strength setting - * - 0: Single-pad drive strength for PTD7. - * - 1: Double pad drive strength for PTD7. - */ -static inline void SIM_HAL_SetPtd7PadDriveStrengthMode(SIM_Type* base, - sim_ptd7pad_strengh_t setting) -{ - SIM_BWR_SOPT2_PTD7PAD(base, setting); -} - -/*! - * @brief Gets the PTD7 pad drive strength setting. - * - * This function gets the PTD7 pad drive strength setting. - * - * @param base Base address for current SIM instance. - * @return setting PTD7 pad drive strength setting - */ -static inline sim_ptd7pad_strengh_t SIM_HAL_GetPtd7PadDriveStrengthMode(SIM_Type* base) -{ - return (sim_ptd7pad_strengh_t)SIM_BRD_SOPT2_PTD7PAD(base); -} -#endif /* FSL_FEATURE_SIM_OPT_HAS_PTD7PAD */ - -#if FSL_FEATURE_SIM_OPT_HAS_FBSL -/*! - * @brief Sets the FlexBus security level setting. - * - * This function sets the FlexBus security level setting. If the security is enabled, - * this field affects which CPU operations can access the off-chip via the FlexBus - * and DDR controller interfaces. This field has no effect if the security is not enabled. - * - * @param base Base address for current SIM instance. - * @param setting FlexBus security level setting - * - 00: All off-chip accesses (op code and data) via the FlexBus and - * DDR controller are disallowed. - * - 10: Off-chip op code accesses are disallowed. Data accesses are - * allowed. - * - 11: Off-chip op code accesses and data accesses are allowed. - */ -static inline void SIM_HAL_SetFlexbusSecurityLevelMode(SIM_Type* base, - sim_flexbus_security_level_t setting) -{ - SIM_BWR_SOPT2_FBSL(base, setting); -} - -/*! - * @brief Gets the FlexBus security level setting. - * - * This function gets the FlexBus security level setting. - * - * @param base Base address for current SIM instance. - * @return setting FlexBus security level setting - */ -static inline sim_flexbus_security_level_t SIM_HAL_GetFlexbusSecurityLevelMode(SIM_Type* base) -{ - return (sim_flexbus_security_level_t)SIM_BRD_SOPT2_FBSL(base); -} -#endif /* FSL_FEATURE_SIM_OPT_HAS_FBSL */ - -#if FSL_FEATURE_SIM_OPT_HAS_PCR -/*! - * @brief Sets the PCR setting. - * - * This function sets the PCR setting. This is the FlexBus hold cycles before - * FlexBus can release bus to NFC or to IDLE. - * - * @param base Base address for current SIM instance. - * @param setting PCR setting - */ -static inline void SIM_HAL_SetFlexbusHoldCycles(SIM_Type* base, uint32_t setting) -{ - SIM_BWR_SOPT6_PCR(base, setting); -} - -/*! - * @brief Gets the PCR setting. - * - * This function gets the PCR setting. - * - * @param base Base address for current SIM instance. - * @return setting PCR setting - */ -static inline uint32_t SIM_HAL_GetFlexbusHoldCycles(SIM_Type* base) -{ - return SIM_BRD_SOPT6_PCR(base); -} -#endif /* FSL_FEATURE_SIM_OPT_HAS_PCR */ - -#if FSL_FEATURE_SIM_OPT_HAS_MCC -/*! - * @brief Sets the MCC setting. - * - * This function sets the MCC setting. This is the NFC hold cycle in case the - * FlexBus request during NFC is granted. - * - * @param base Base address for current SIM instance. - * @param setting MCC setting - */ -static inline void SIM_HAL_SetNandFlashControllerHoldCycles(SIM_Type* base, uint32_t setting) -{ - SIM_BWR_SOPT6_MCC(base, setting); -} - -/*! - * @brief Gets the MCC setting. - * - * This function gets the MCC setting. - * - * @param base Base address for current SIM instance. - * @return setting MCC setting - */ -static inline uint32_t SIM_HAL_GetNandFlashControllerHoldCycles(SIM_Type* base) -{ - return SIM_BRD_SOPT6_MCC(base); -} -#endif /* FSL_FEATURE_SIM_OPT_HAS_MCC */ - -/*! - * @brief Sets the FlexTimer x external clock pin select setting. - * - * This function selects the source of FTMx external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select FTMx external clock pin select - * - 0: FTMx external clock driven by FTM CLKIN0 pin. - * - 1: FTMx external clock driven by FTM CLKIN1 pin. - */ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance, - sim_ftm_clk_sel_t select); - -/*! - * @brief Gets the FlexTimer x external clock pin select setting. - * - * This function gets the FlexTimer x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select FlexTimer x external clock pin select setting - */ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance); - -/*! - * @brief Sets the FlexTimer x channel y input capture source select setting. - * - * This function selects the FlexTimer x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y input capture source - */ -void SIM_HAL_SetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y input capture source select setting. - * - * This function gets the FlexTimer x channel y input capture - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y input capture source select setting - */ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Sets the FlexTimer x channel y output source select setting. - * - * This function selects the FlexTimer x channel y output source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y output source - */ -void SIM_HAL_SetFtmChOutSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_out_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y output source select setting. - * - * This function gets the FlexTimer x channel y output - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y output source select setting - */ -sim_ftm_ch_out_src_t SIM_HAL_GetFtmChOutSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief sets FlexTimer x carrier frequency selection setting - * - * This function sets the FTMx output channel carrier frequency selection setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param ftmcarrierfreqsrc FTMx output channel carrier frequency selection - */ -void SIM_HAL_SetFtmCarrierFreqCmd(SIM_Type* base, uint32_t instance, bool ftmcarrierfreqsrc); - -/*! - * @brief Gets the FlexTimer x carrier frequency selection setting. - * - * This function gets the FTMx output channel carrier frequency selection setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return value indicates FTMx output channel carrier frequency selection - */ -bool SIM_HAL_GetFtmCarrierFreqCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief sets FlexTimer x hardware trigger 0 software synchronization - * - * This function enables/disables the alternative hardware triggers for FTMx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param sync assert TRIG0 input to FTM0 - */ -void SIM_HAL_SetFtmSyncCmd(SIM_Type* base, uint32_t instance, bool sync); - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param convId Selection of ID for ADC converter. - * @param enable Enable alternative conversion triggers for ADCx - * - Enable an alternative conversion trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type* base, sim_cadc_conv_id_t convId, sim_adc_alt_trg_en enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param convId Selection of ID for ADC converter. - * @return value indicates ADCx alternate trigger selection - */ -sim_adc_alt_trg_en SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type* base, sim_cadc_conv_id_t convId); - - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param convId Selection of ID for ADC converter. - * @param select trigger select setting for ADCx - * - 0000: External trigger - * - 0001: High speed comparator 0 asynchronous interrupt - * - 0010: High speed comparator 1 asynchronous interrupt - * - 0011: High speed comparator 2 asynchronous interrupt - * - 0100: PIT trigger 0 - * - 0101: PIT trigger 1 - * - 0110: PIT trigger 2 - * - 0111: PIT trigger 3 - * - 1000: FTM0 trigger - * - 1001: FTM1 trigger - * - 1010: FTM2 trigger - * - 1011: FTM3 trigger - * - 1100: RTC alarm - * - 1101: RTC seconds - * - 1110: Low-power timer trigger - * - 1111: High speed comparator 3 asynchronous interrupt -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type* base, sim_cadc_conv_id_t convId, sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param convId Selection of ID for ADC converter. - * @return select ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type* base, sim_cadc_conv_id_t convId); - -/*! - * @brief Set ADCx trigger setting. - * - * This function sets ADC alternate trigger and trigger mode. - * - * @param base Base address for current SIM instance. - * @param convId device instance. - * @param altTrigEn alternate trigger enable - * @param trigSel 00 XBARA output 12, 01 PDB0 trigger selected for ADCA, 1- Alternate trigger selected for ADCA. - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type* base, sim_cadc_conv_id_t convId, - bool altTrigEn, sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - * - 00: UARTx_RX pin. - * - 01: CMP0. - * - 10: CMP1. - * - 11: Reserved. - */ -void SIM_HAL_SetUartRxSrcMode(SIM_Type* base, uint32_t instance, sim_uart_rxsrc_t select); - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type* base, uint32_t instance); - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - * - 00: UARTx_TX pin. - * - 01: UARTx_TX pin modulated with FTM1 channel 0 output. - * - 10: UARTx_TX pin modulated with FTM2 channel 0 output. - * - 11: Reserved. - */ -void SIM_HAL_SetUartTxSrcMode(SIM_Type* base, uint32_t instance, sim_uart_txsrc_t select); - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type* base, uint32_t instance); - -#if FSL_FEATURE_SIM_OPT_HAS_ODE -/*! - * @brief Sets the UARTx Open Drain Enable setting. - * - * This function enables/disables the UARTx Open Drain. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable/disable UARTx Open Drain - * - True: Enable UARTx Open Drain - * - False: Disable UARTx Open Drain - */ -void SIM_HAL_SetUartOpenDrainCmd(SIM_Type* base, uint8_t instance, bool enable); - -/*! - * @brief Gets the UARTx Open Drain Enable setting. - * - * This function gets the UARTx Open Drain Enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if UARTx Open Drain is enabled. - */ -bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type* base, uint8_t instance); -#endif - -#if FSL_FEATURE_SIM_OPT_HAS_FTM -/*! - * @brief Sets the FlexTimer x hardware trigger y source select setting. - * - * This function selects the source of FTMx hardware trigger y. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @param select FlexTimer x hardware trigger y - * - 0: Pre-trigger A selected for ADCx. - * - 1: Pre-trigger B selected for ADCx. - */ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select); - -/*! - * @brief Gets the FlexTimer x hardware trigger y source select setting. - * - * This function gets the FlexTimer x hardware trigger y source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @return select FlexTimer x hardware trigger y source select setting - */ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type* base, uint32_t instance, uint8_t trigger); - -/*! - * @brief Sets the FlexTimer x fault y select setting. - * - * This function sets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @param select FlexTimer x fault y select setting - * - 0: FlexTimer x fault y select 0. - * - 1: FlexTimer x fault y select 1. - */ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type* base, uint8_t instance, uint8_t fault, sim_ftm_flt_sel_t select); - -/*! - * @brief Gets the FlexTimer x fault y select setting. - * - * This function gets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @return select FlexTimer x fault y select setting - */ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type* base, uint8_t instance, uint8_t fault); -#endif - -#if FSL_FEATURE_SIM_OPT_HAS_TPM -/*! - * @brief Sets the Timer/PWM x external clock pin select setting. - * - * This function selects the source of the Timer/PWM x external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select Timer/PWM x external clock pin select - * - 0: Timer/PWM x external clock driven by the TPM_CLKIN0 pin. - * - 1: Timer/PWM x external clock driven by the TPM_CLKIN1 pin. - */ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type* base, uint8_t instance, sim_tpm_clk_sel_t select); - -/*! - * @brief Gets the Timer/PWM x external clock pin select setting. - * - * This function gets the Timer/PWM x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select Timer/PWM x external clock pin select setting - */ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type* base, uint8_t instance); - -/*! - * @brief Sets the Timer/PWM x channel y input capture source select setting. - * - * This function selects the Timer/PWM x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel TPM channel y - * @param select Timer/PWM x channel y input capture source - * - 0: TPMx_CH0 signal - * - 1: CMP0 output - */ -void SIM_HAL_SetTpmChSrcMode(SIM_Type* base, uint8_t instance, uint8_t channel, sim_tpm_ch_src_t select); - -/*! - * @brief Gets the Timer/PWM x channel y input capture source select setting. - * - * This function gets the Timer/PWM x channel y input capture source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel Tpm channel y - * @return select Timer/PWM x channel y input capture source select setting - */ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type* base, uint8_t instance, uint8_t channel); -#endif - -#if FSL_FEATURE_SIM_SDID_HAS_FAMILYID -/*! - * @brief Gets the Kinetis Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Family ID in the System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Family ID - */ -static inline uint32_t SIM_HAL_GetFamilyId(SIM_Type* base) -{ - return SIM_BRD_SDID_FAMILYID(base); -} -#endif - -#if FSL_FEATURE_SIM_SDID_HAS_SUBFAMID -/*! - * @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Sub-Family ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Sub-Family ID - */ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type* base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} -#endif - -#if FSL_FEATURE_SIM_SDID_HAS_SERIESID -/*! - * @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Series ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Series ID - */ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type* base) -{ - return SIM_BRD_SDID_SERIESID(base); -} -#endif - -#if FSL_FEATURE_SIM_SDID_HAS_FAMID -/*! - * @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Fam ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Fam ID - */ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type* base) -{ - return SIM_BRD_SDID_FAMID(base); -} -#endif - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type* base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type* base) -{ - return SIM_BRD_SDID_REVID(base); -} - -#if FSL_FEATURE_SIM_SDID_HAS_DIEID -/*! - * @brief Gets the Kinetis Die ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Die ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Die ID - */ -static inline uint32_t SIM_HAL_GetDieId(SIM_Type* base) -{ - return SIM_BRD_SDID_DIEID(base); -} -#endif - -#if FSL_FEATURE_SIM_SDID_HAS_SRAMSIZE -/*! - * @brief Gets the Kinetis SRAM size in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis SRAM Size in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis SRAM Size - */ -static inline uint32_t SIM_HAL_GetSramSize(SIM_Type* base) -{ - return SIM_BRD_SDID_SRAMSIZE(base); -} -#endif - -#if FSL_FEATURE_SIM_FCFG_HAS_NVMSIZE -/*! - * @brief Gets the FlexNVM size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size FlexNVM Size - */ -static inline uint32_t SIM_HAL_GetFlexnvmSize(SIM_Type* base) -{ - return SIM_BRD_FCFG1_NVMSIZE(base); -} -#endif - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type* base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -#if FSL_FEATURE_SIM_FCFG_HAS_EESIZE -/*! - * @brief Gets the EEProm size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the EEProm size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size EEProm Size - */ -static inline uint32_t SIM_HAL_GetEepromSize(SIM_Type* base) -{ - return SIM_BRD_FCFG1_EESIZE(base); -} -#endif - -#if FSL_FEATURE_SIM_FCFG_HAS_DEPART -/*! - * @brief Gets the FlexNVM partition in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM partition in the Flash Configuration Register 1 - * - * @param base Base address for current SIM instance. - * @return setting FlexNVM partition setting - */ -static inline uint32_t SIM_HAL_GetFlexnvmPartition(SIM_Type* base) -{ - return SIM_BRD_FCFG1_DEPART(base); -} -#endif - -#if FSL_FEATURE_SIM_FCFG_HAS_FLASHDOZE -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type* base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type* base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} -#endif - -#if FSL_FEATURE_SIM_FCFG_HAS_FLASHDIS -/*! - * @brief Sets the Flash disable setting in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash disable setting in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type* base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash disable setting in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type* base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} -#endif - -#if FSL_FEATURE_SIM_FCFG_HAS_MAXADDR0 -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type* base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} -#endif - -#if FSL_FEATURE_SIM_FCFG_HAS_MAXADDR1 -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type* base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} -#endif - -#if FSL_FEATURE_SIM_FCFG_HAS_MAXADDR01 -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock01(SIM_Type* base) -{ - return SIM_BRD_FCFG2_MAXADDR01(base); -} -#endif - -#if FSL_FEATURE_SIM_FCFG_HAS_MAXADDR23 -/*! - * @brief Gets the Flash maximum address block 1 in the Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock23(SIM_Type* base) -{ - return SIM_BRD_FCFG2_MAXADDR23(base); -} -#endif - -#if FSL_FEATURE_SIM_FCFG_HAS_PFLSH -/*! - * @brief Gets the program flash in the Flash Configuration Register 2. - * - * This function gets the program flash maximum block 0 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return status program flash status - */ -static inline uint32_t SIM_HAL_GetProgramFlashCmd(SIM_Type* base) -{ - return SIM_BRD_FCFG2_PFLSH(base); -} -#endif - -/*! - * @brief Sets the Debug Trace Divider Control. - * - * This function sets the Debug Trace Divider enable setting. - * - * @param base Base address for current SIM instance. - * @param enable Debug trace divider control enable setting - */ -static inline void SIM_HAL_SetDebugTraceDivEnCmd(SIM_Type* base, bool enable) -{ - SIM_BWR_CLKDIV4_TRACEDIVEN(base, enable); -} - -/*! - * @brief Gets the Debug Trace Divider Control. - * - * This function gets the Debug Trace Divider enable setting. - * - * @param base Base address for current SIM instance. - * @return enable Debug trace divider control enable setting - */ -static inline bool SIM_HAL_GetDebugTraceDivEnCmd(SIM_Type* base) -{ - return (bool)SIM_BRD_CLKDIV4_TRACEDIVEN(base); -} - -/*! - * @brief Sets the Debug Trace Divider Divisor. - * - * This function sets the Debug Trace Divider Divisor value. - * - * @param base Base address for current SIM instance. - * @param divisor_value divide value for the fractional clock divider - */ -static inline void SIM_HAL_SetDebugTraceDivDivisor(SIM_Type* base, uint8_t divisor_value) -{ - SIM_BWR_CLKDIV4_TRACEDIV(base, divisor_value); -} - -/*! - * @brief Gets the Debug Trace Divider Divisor value. - * - * This function gets the Debug Trace Divider enable setting. - * - * @param base Base address for current SIM instance. - * @return divisor_value divide value for the fractional clock divider - */ -static inline uint8_t SIM_HAL_GetDebugTraceDivDivisor(SIM_Type* base) -{ - return (bool)SIM_BRD_CLKDIV4_TRACEDIV(base); -} - -/*! - * @brief Sets the Debug Trace Divider Divisor. - * - * This function sets the Debug Trace Divider Divisor value. - * - * @param base Base address for current SIM instance. - * @param divisor_frac_value divide value for the fractional clock divider - */ -static inline void SIM_HAL_SetDebugTraceFracDivDivisor(SIM_Type* base, bool divisor_frac_value) -{ - SIM_BWR_CLKDIV4_TRACEFRAC(base, divisor_frac_value); -} - -/*! - * @brief Gets the Debug Trace Divider Divisor value. - * - * This function gets the Debug Trace Divider enable setting. - * - * @param base Base address for current SIM instance. - * @return divisor_frac_value divide value for the fractional clock divider - */ -static inline uint8_t SIM_HAL_GetDebugTraceFracDivDivisor(SIM_Type* base) -{ - return (bool)SIM_BRD_CLKDIV4_TRACEFRAC(base); -} - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type* base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type* base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type* base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! @name IP related clock feature APIs*/ -/*@{*/ -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type* base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type* base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV2. - * - * This function sets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv2(SIM_Type* base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV2(base, setting); -} - -/*! - * @brief Get OUTDIV2. - * - * This function gets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv2(SIM_Type* base) -{ - return SIM_BRD_CLKDIV1_OUTDIV2(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type* base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type* base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableDmaClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableDmaClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetDmaGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableDmamuxClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableDmamuxClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetDmamuxGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnablePortClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisablePortClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetPortGateCmd(SIM_Type* base, uint32_t instance); - - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableEwmClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableEwmClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetEwmGateCmd(SIM_Type* base, uint32_t instance); - - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableFtfClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableFtfClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetFtfGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableCrcClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableCrcClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetCrcGateCmd(SIM_Type* base, uint32_t instance); - - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableAdcClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableAdcClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetAdcGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableCmpClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableCmpClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetCmpGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableDacClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableDacClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetDacGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnablePdbClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisablePdbClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetPdbGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableFtmClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableFtmClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetFtmGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Set the ADC x (0-A, 1-B)channel y (6,7) Mux - * - * This function selects ADCx MUXy's channel to ADCx channel y. - * - * - * @param base Base address for current SIM instance. - * @param instance ADC module instance (0-A, 1-B) - * @param channel channel number (6,7) - * @param select Refer to RM for specific channel settings - * - *END**************************************************************************/ -void SIM_HAL_SetAdcxMuxSelChannely(SIM_Type* base, uint32_t instance, - uint8_t channel, uint8_t select); - -/*! - * @brief Get the ADC x (0-A, 1-B)channel y (6,7) Mux - * - * This function gets the ADCx MUXy's channel to ADCx channel y. - * - * - * @param base Base address for current SIM instance. - * @param instance ADC module instance (0-A, 1-B) - * @param channel channel number (6,7) - * @return select Refer to RM for specific channel settings - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetAdcxMuxSelChannely(SIM_Type* base, uint32_t instance, uint8_t channel); - -/*! - * @brief Set Nanoedge Regulator 1.2 V Supply Standby Control - * - * This function controls the standby mode of the 1.2 V supply from the nanoedge voltage regulator. - * - * @param base Base address for current SIM instance. - * @param select: - * 00 Nanoedge regulator 1.2 V supply placed in normal mode - * 01 Nanoedge regulator 1.2 V supply placed in standby mode. - * 10 Nanoedge regulator 1.2 V supply placed in normal mode and SR12STDBY is write protected until - * chip reset. - * 11 Nanoedge regulator 1.2 V supply placed in standby mode and SR12STDBY is write protected until - * chip reset. - * - *END**************************************************************************/ -void SIM_HAL_SetNanoedgeRegulator12SupStdbyControl(SIM_Type* base, uint8_t select); - -/*! - * - * @brief Get Nanoedge Regulator 1.2 V Supply Standby Control - * - * This function will get the standby mode of the 1.2 V supply from the nanoedge voltage regulator - * @param base Base address for current SIM instance. - * @return select: - * 00 Nanoedge regulator 1.2 V supply placed in normal mode - * 01 Nanoedge regulator 1.2 V supply placed in standby mode. - * 10 Nanoedge regulator 1.2 V supply placed in normal mode and SR12STDBY is write protected until - * chip reset. - * 11 Nanoedge regulator 1.2 V supply placed in standby mode and SR12STDBY is write protected until - * chip reset. - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetNanoedgeRegulator12SupStdbyControl(SIM_Type* base); - -/*! - * @brief Set Nanoedge Regulator 2.7 V Supply Standby Control - * - * This function controls the standby mode of the 2.7 V supply from the nanoedge voltage regulator. - * - * @param base Base address for current SIM instance. - * @param select: - * 00 Nanoedge regulator 2.7 V supply placed in normal mode - * 01 Nanoedge regulator 2.7 V supply placed in standby mode. - * 10 Nanoedge regulator 2.7 V supply placed in normal mode and SR12STDBY is write protected until - * chip reset. - * 11 Nanoedge regulator 2.7 V supply placed in standby mode and SR12STDBY is write protected until - * chip reset. - * - * - *END**************************************************************************/ -void SIM_HAL_SetNanoedgeRegulator27SupStdbyControl(SIM_Type* base, uint8_t select); - -/*! - * @brief Get Nanoedge Regulator 2.7 V Supply Standby Control - * - * This function will get the standby mode of the 2.7 V supply from the nanoedge voltage regulator. - * - * @param base Base address for current SIM instance. - * @return select: - * 00 Nanoedge regulator 2.7 V supply placed in normal mode - * 01 Nanoedge regulator 2.7 V supply placed in standby mode. - * 10 Nanoedge regulator 2.7 V supply placed in normal mode and SR12STDBY is write protected until - * chip reset. - * 11 Nanoedge regulator 2.7 V supply placed in standby mode and SR12STDBY is write protected until - * chip reset. - * - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetNanoedgeRegulator27SupStdbyControl(SIM_Type* base); - -/*! - * - * @brief Set Nanoedge Regulator 2.7V and 1.2V Supply Powerdown Control - * - * This function controls the powerdown mode of the 2.7V and 1.2V supply from the nanoedge voltage regulator - * - * @param base Base address for current SIM instance. - * @param select: - * 00 Nanoedge regulator placed in normal mode. - * 01 Nanoedge regulator placed in powerdown mode. - * 10 Nanoedge regulator placed in normal mode and SRPDN is write protected until chip reset. - * 11 Nanoedge regulator placed in powerdown mode and SRPDN is write protected until chip reset. - * - *END**************************************************************************/ -void SIM_HAL_SetNanoedgeReg27n12SupPwrdwnControl(SIM_Type* base, uint8_t select); - -/*! - * - * @brief Get Nanoedge Regulator 2.7V and 1.2V Supply Powerdown Control - * - * This function gets the the powerdown mode of the 2.7V and 1.2V supply from the nanoedge voltage regulator - * - * @param base Base address for current SIM instance. - * @return select: - * 00 Nanoedge regulator placed in normal mode. - * 01 Nanoedge regulator placed in powerdown mode. - * 10 Nanoedge regulator placed in normal mode and SRPDN is write protected until chip reset. - * 11 Nanoedge regulator placed in powerdown mode and SRPDN is write protected until chip reset. - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetNanoedgeReg27n12SupPwrdwnControl(SIM_Type* base); - -/*! - * - * @brief WDOG Clock Select - * - * This function selects the clock source of the WDOG2008 watchdog. - * - * @param base Base address for current SIM instance. - * @param select: - * 0 Internal 1 kHz clock is source to WDOG2008 - * 1 MCGIRCLK is source to WDOG2008 - * - *END**************************************************************************/ -void SIM_HAL_SetWdogClkSrc(SIM_Type* base, bool select); - -/*! - * - * @brief Get WDOG Clock Src - * - * This function gets the clock source of the WDOG2008 watchdog. - * - * @param base Base address for current SIM instance. - * @return select: - * 0 Internal 1 kHz clock is source to WDOG2008 - * 1 MCGIRCLK is source to WDOG2008 - * - *END**************************************************************************/ -bool SIM_HAL_GetWdogClkSrc(SIM_Type* base); - -/*! - * - * @brief Synchronize XBARA's Input PIT Trigger X with fast clock - * - * This function enables the synchronizer between PIT trigger X and XBARA's input. - * - * @param base Base address for current SIM instance. - * @param instance Pit trigger number - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarAPittrigX(SIM_Type* base, uint32_t instance); - -/*! - * - * @brief Synchronize XBARA's Input PIT Trigger X with fast clock - * - * This function disables the synchronizer between PIT trigger X and XBARA's input. - * - * @param base Base address for current SIM instance. - * @param instance Pit trigger number - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarAPittrigX(SIM_Type* base, uint32_t instance); - -/*! - * - * @brief get Synchronization of XBARA's Input PIT Trigger X with fast clock - * - * This function returns the status of the synchronizer between PIT trigger X and XBARA's input. - * - * @param base Base address for current SIM instance. - * @param instance Pit trigger number - * @return 0 - Not synchronizeed, 1- Synchronized - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarAPittrigXcmd(SIM_Type* base, uint32_t instance); - -/*! - * - * @brief Synchronize XBARB's Input PIT Trigger X with fast clock - * - * This function enables the synchronizer between PIT trigger X and XBARB's input. - * - * @param base Base address for current SIM instance. - * @param instance Pit trigger number - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarBPittrigX(SIM_Type* base, uint32_t instance); - -/*! - * - * @brief Synchronize XBARB's Input PIT Trigger X with fast clock - * - * This function disables the synchronizer between PIT trigger X and XBARB's input. - * - * @param base Base address for current SIM instance. - * @param instance Pit trigger number - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarBPittrigX(SIM_Type* base, uint32_t instance); - -/*! - * - * @brief get Synchronization of XBARB's Input PIT Trigger X with fast clock - * - * This function returns the status of the synchronizer between PIT trigger X and XBARB's input. - * - * @param base Base address for current SIM instance. - * @param instance Pit trigger number - * @return 0 - Not synchronizeed, 1- Synchronized - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarBPittrigXcmd(SIM_Type* base, uint32_t instance); - -/*! - * - * @brief Synchronize XBARA's output for DAC Hardware Trigger with flash/slow clock - * - * This function controls the synchronizer between XBARA's output and DAC hardware trigger. - * - * @param base Base address for current SIM instance. - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarDac(SIM_Type* base); - -/*! - * - * @brief Synchronize XBARA's output for DAC Hardware Trigger with flash/slow clock - * - * This function Disables the synchronizer between XBARA's output and DAC hardware trigger - * - * @param base Base address for current SIM instance. - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarDac(SIM_Type* base); - -/*! - * - * @brief Get the synchronizer cmd between XBARA's output and DAC hardware trigger - * - * @param base Base address for current SIM instance. - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarDaccmd(SIM_Type* base); - -/*! - * - * @brief Get the synchronizer cmd between XBARA's output and EWM's ewm_in - * - * This function enables the synchronizer between XBARA's output and EWM's ewm_in - * - * @param base Base address for current SIM instance. - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarEwmin(SIM_Type* base); - -/*! - * - * @brief Disable the synchronizer between XBARA's output and EWM's ewm_in - * - * This function Disables the synchronizer between XBARA's output and EWM's ewm_in - * - * @param base Base address for current SIM instance. - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarEwmin(SIM_Type* base); - -/*! - * - * @brief Get the synchronizer cmd between XBARA's output and EWM's ewm_in - * - * @param base Base address for current SIM instance. - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarEwmincmd(SIM_Type* base); - -/*! - * - * @brief Enable the the synchronizer between XBARA's output and CMPx's sample/window input - * - * This function enables the the synchronizer between XBARA's output and CMPx's sample/window input - * - * @param base Base address for current SIM instance. - * @param instance comaprator instance - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarCmpX(SIM_Type* base, uint32_t instance); - -/*! - * - * @brief Disable the synchronizer between XBARA's output and CMP3's sample/window input - * - * This function Disables the synchronizer between XBARA's output and CMP3's sample/window input - * - * @param base Base address for current SIM instance. - * @param instance comaprator instance - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarCmpX(SIM_Type* base, uint32_t instance); - -/*! - * - * @brief Get the synchronizer cmd between XBARA's output and CMP3's sample/window input - * - * @param base Base address for current SIM instance. - * @param instance comaprator instance - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarCmpXcmd(SIM_Type* base, uint32_t instance); - -/*! - * - * @brief Set CMP Sample/Window Input X Source - * - * This function controls the sample/window source of CMP module - * - * @param base Base address for current SIM instance. - * @param instance comaprator instance - * @param select CMP Sample/Window Input X Source - * 00 XBARA output - refer RM for specific cmp instance - * 01 CMPx Sample/Window input is driven by both PDB0 and PDB1 pluse-out channel 0. - * 10 PDB0 pluse-out channel 0. - * 11 PDB1 pluse-out channel 0. - *END**************************************************************************/ -void SIM_HAL_SetCmpWinxSrc(SIM_Type* base, uint32_t instance, - sim_cmp_win_in_src select); - -/*! - * - * @brief Get CMP Sample/Window Input X Source - * - * This function will get the sample/window source of CMP module - * - * @param base Base address for current SIM instance. - * @param instance comaprator instance - * @return select CMP Sample/Window Input X Source - * 00 XBARA output - refer RM for specific cmp instance - * 01 CMPx Sample/Window input is driven by both PDB0 and PDB1 pluse-out channel 0. - * 10 PDB0 pluse-out channel 0. - * 11 PDB1 pluse-out channel 0. - *END**************************************************************************/ -sim_cmp_win_in_src SIM_HAL_GetCmpWinxSrc(SIM_Type* base, uint32_t instance); - -/*! - * - * @brief Set EWM_IN source setting - * - * This function controls the ewm_in source of EWM module - * - * @param base Base address for current SIM instance. - * @param select EWM_IN source , 0-XBARA output 58, 1-EWM_IN pin - * - *END**************************************************************************/ -void SIM_HAL_SetEwmInSrc(SIM_Type* base, sim_ewm_in_src select); - -/*! - * - * @brief Get EWM_IN source setting - * - * This function will get the ewm_in source of EWM module - * @param base Base address for current SIM instance. - * @return select EWM_IN source , 0-XBARA output 58, 1-EWM_IN pin - * - *END**************************************************************************/ -sim_ewm_in_src SIM_HAL_GetEwmInSrc(SIM_Type* base); - -/*! - * - * @brief Set DAC x Hardware trigger source setting - * - * This function will select the DAC0 Hardware Trigger Input Source - * - * @param base Base address for current SIM instance. - * @param select DAC0 Hardware Trigger Input Source - * 00 XBARA output 15. - * 01 DAC0 can be triggered by both PDB0 interval trigger 0 and PDB1 interval trigger 0. - * 10 PDB0 interval trigger 0 - * 11 PDB1 interval trigger 0 - *END**************************************************************************/ -void SIM_HAL_SetDacHwTrigSrc(SIM_Type* base,sim_dac_hw_trg_sel select); - -/*! - * - * @brief Get DAC x Hardware trigger source setting - * - * This function will get the DAC0 Hardware Trigger Input Source - * - * @param base Base address for current SIM instance. - * @param instance DAC instance. - * @return select DAC0 Hardware Trigger Input Source - * 00 XBARA output 15. - * 01 DAC0 can be triggered by both PDB0 interval trigger 0 and PDB1 interval trigger 0. - * 10 PDB0 interval trigger 0 - * 11 PDB1 interval trigger 0 - *END**************************************************************************/ -sim_dac_hw_trg_sel SIM_HAL_GetDacHwTrigSrc(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnablePitClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisablePitClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetPitGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableLptmrClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableLptmrClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetLptmrGateCmd(SIM_Type* base, uint32_t instance); - - -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableFlexcanClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableFlexcanClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetFlexcanGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableSpiClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableSpiClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetSpiGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableI2cClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableI2cClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetI2cGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableUartClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableUartClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetUartGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for eFlexPWM module. - * - * This function enables the clock for eFlexPWM moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnablePwmClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for eFlexPWM module. - * - * This function disables the clock for eFlexPWM moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisablePwmClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for eFlexPWM module. - * - * This function will get the clock gate state for eFlexPWM moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetPwmGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for AOI module. - * - * This function enables the clock for AOI moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableAoiClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for AOI module. - * - * This function disables the clock for AOI moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableAoiClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for AOI module. - * - * This function will get the clock gate state for AOI moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetAoiGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for XBAR module. - * - * This function enables the clock for XBAR moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableXbarClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for XBAR module. - * - * This function disables the clock for XBAR moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableXbarClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for XBAR module. - * - * This function will get the clock gate state for XBAR moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetXbarGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Enable the clock for ENC module. - * - * This function enables the clock for ENC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_EnableEncClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Disable the clock for ENC module. - * - * This function disables the clock for ENC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - */ -void SIM_HAL_DisableEncClock(SIM_Type* base, uint32_t instance); - -/*! - * @brief Get the the clock gate state for ENC module. - * - * This function will get the clock gate state for ENC moudle. - * - * @param base Base address for current SIM instance. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool SIM_HAL_GetEncGateCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type* base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type* base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set debug trace clock selection. - * - * This function sets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTraceClkSrc(SIM_Type* base, clock_trace_src_t setting) -{ - SIM_BWR_SOPT2_TRACECLKSEL(base, setting); -} - -/*! - * @brief Get debug trace clock selection. - * - * This function gets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_trace_src_t CLOCK_HAL_GetTraceClkSrc(SIM_Type* base) -{ - return (clock_trace_src_t)SIM_BRD_SOPT2_TRACECLKSEL(base); -} - -/*! - * @brief Set Nanoedge clock selection. - * - * This function sets Nanoedge clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetNanoedgeClkSrc(SIM_Type* base, clock_nanoedge_clk2x_src setting) -{ - SIM_BWR_SOPT2_NANOEDGECLK2XSEL(base, setting); -} - -/*! - * @brief Get Nanoedge clock selection. - * - * This function gets Nanoedge clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_nanoedge_clk2x_src CLOCK_HAL_GetNanoedgeClkSrc(SIM_Type* base) -{ - return (clock_nanoedge_clk2x_src)SIM_BRD_SOPT2_NANOEDGECLK2XSEL(base); -} - -/*! - * @brief Get Nanoedge PMC Status - * - * This function gets Nanoedge power supply status. - * - * @param base Base address for current SIM instance. - * @return power supply status. - */ -static inline bool CLOCK_HAL_GetNanoedgePMCStatus(SIM_Type* base) -{ - return (bool)SIM_BRD_PWRC_SRPWROK(base); -} -/*@}*/ - -/*! - * @brief Set Nanoedge PMC POWER Ready - * - * This function sets soft control to indicate nanoedge PMC is ready, - * when PMC Power dectect is disabled by SRPWRDETEN - * @param base Base address for current SIM instance. - * @param select power supply status. - */ -static inline void CLOCK_HAL_SetNanoedgePMCPwrRdy(SIM_Type* base, bool select) -{ - SIM_BWR_PWRC_SRPWRRDY(base, select); -} - -/*! - * @brief Get Nanoedge PMC POWER Ready - * - * This function gets soft control to indicate nanoedge PMC is ready. - * - * @param base Base address for current SIM instance. - * @return power supply status. - */ -static inline bool CLOCK_HAL_GetNanoedgePMCPwrRdy(SIM_Type* base) -{ - return (bool)SIM_BRD_PWRC_SRPWRRDY(base); -} -/*@}*/ - -/*! - * @brief Nanoedge PMC POWER Dectect Enable - * - * enable Nanoedge PMC power dectect to assert PMC ready signal when PMC is stable. - * - * @param base Base address for current SIM instance. - * - */ -static inline void CLOCK_HAL_EnableNanoedgePmcPowerDectect (SIM_Type* base) -{ - SIM_BWR_PWRC_SRPWRDETEN(base, 1); -} - -/*! - * @brief Nanoedge PMC POWER Dectect Disable - * - * disable Nanoedge PMC power dectect to assert PMC ready signal when PMC is stable. - * - * @param base Base address for current SIM instance. - * - */ -static inline void CLOCK_HAL_DisableNanoedgePmcPowerDectect (SIM_Type* base) -{ - SIM_BWR_PWRC_SRPWRDETEN(base, 0); -} - -/*! - * @brief Get Nanoedge PMC POWER Dectect - * - * This function gets Nanoedge PMC power dectect to assert PMC ready signal when PMC is stable - * - * @param base Base address for current SIM instance. - * @return PMC power dectect status. - */ -static inline bool CLOCK_HAL_GetNanoedgePmcPowerDectectcmd(SIM_Type* base) -{ - return (bool)SIM_BRD_PWRC_SRPWRDETEN(base); -} - -/*! - * @brief Get ADC Clock Status - * - * This function returns which clock is fed in ADC. - * 0 ADC clock is fast peripherial clock. - * 1 ADC clock is MCGIRCLK. - * - * @param base Base address for current SIM instance. - * @return ADC Clock Status. - */ -static inline bool CLOCK_HAL_GetAdcClkStatus(SIM_Type* base) -{ - return (bool)SIM_BRD_ADCOPT_ADCIRCLK(base); -} - -/*! - * @brief Enable ADC low current Mode - * - * Control ADC low current mode in STOP and VLPS mode. - * - * @param base Base address for current SIM instance. - * - */ -static inline void CLOCK_HAL_EnableAdcLowCurrentMode(SIM_Type* base) -{ - SIM_BWR_ADCOPT_ROSB(base, 1); -} - -/*! - * @brief Disable ADC low current Mode - * - * Control ADC low current mode in STOP and VLPS mode. - * - * @param base Base address for current SIM instance. - * - */ -static inline void CLOCK_HAL_DisableAdcLowCurrentMode(SIM_Type* base) -{ - SIM_BWR_ADCOPT_ROSB(base, 0); -} - -/*! - * @brief Get ADC low current Mode - * - * This function gets ADC low current mode in STOP and VLPS mode. - * - * @param base Base address for current SIM instance. - * @return ADC low current mode status. - */ -static inline bool CLOCK_HAL_GetAdcLowCurrentModecmd(SIM_Type* base) -{ - return (bool)SIM_BRD_ADCOPT_ROSB(base); -} -/*@}*/ - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - - -/*! @}*/ - -#endif /* __FSL_SIM_HAL_KV44F15_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKV45F15/fsl_sim_hal_MKV45F15.c b/KSDK_1.2.0/platform/hal/src/sim/MKV45F15/fsl_sim_hal_MKV45F15.c deleted file mode 100755 index b7d3672..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKV45F15/fsl_sim_hal_MKV45F15.c +++ /dev/null @@ -1,2694 +0,0 @@ -/* - * Copyright (c) 2014 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type* base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type* base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableDmaClock - * Description : Enable the clock for DMA module - * This function enables the clock for DMA moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableDmaClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC7_DMA(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableDmaClock - * Description : Disable the clock for DMA module - * This function disables the clock for DMA moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableDmaClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC7_DMA(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetDmaGateCmd - * Description : Get the the clock gate state for DMA module - * This function will get the clock gate state for DMA moudle - * - *END**************************************************************************/ -bool SIM_HAL_GetDmaGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC7_DMA(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableDmamuxClock - * Description : Enable the clock for DMAMUX module - * This function enables the clock for DMAMUX moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableDmamuxClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_DMAMUX(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableDmamuxClock - * Description : Disable the clock for DMAMUX module - * This function disables the clock for DMAMUX moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableDmamuxClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_DMAMUX(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetDmamuxGateCmd - * Description : Get the the clock gate state for DMAMUX module - * This function will get the clock gate state for DMAMUX moudle - * - *END**************************************************************************/ -bool SIM_HAL_GetDmamuxGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC6_DMAMUX(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void SIM_HAL_EnablePortClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC5_PORTA(base, 1); - break; - case 1: - SIM_BWR_SCGC5_PORTB(base, 1); - break; - case 2: - SIM_BWR_SCGC5_PORTC(base, 1); - break; - case 3: - SIM_BWR_SCGC5_PORTD(base, 1); - break; - case 4: - SIM_BWR_SCGC5_PORTE(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void SIM_HAL_DisablePortClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC5_PORTA(base, 0); - break; - case 1: - SIM_BWR_SCGC5_PORTB(base, 0); - break; - case 2: - SIM_BWR_SCGC5_PORTC(base, 0); - break; - case 3: - SIM_BWR_SCGC5_PORTD(base, 0); - break; - case 4: - SIM_BWR_SCGC5_PORTE(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetPortGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_SCGC5_PORTA(base); - break; - case 1: - retValue = SIM_BRD_SCGC5_PORTB(base); - break; - case 2: - retValue = SIM_BRD_SCGC5_PORTC(base); - break; - case 3: - retValue = SIM_BRD_SCGC5_PORTD(base); - break; - case 4: - retValue = SIM_BRD_SCGC5_PORTE(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableEwmClock - * Description : Enable the clock for EWM module - * This function enables the clock for EWM moudle. - * - *END**************************************************************************/ -void SIM_HAL_EnableEwmClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC4_EWM(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableEwmClock - * Description : Disable the clock for EWM modul - * This function disables the clock for EWM moudle. - * - *END**************************************************************************/ -void SIM_HAL_DisableEwmClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC4_EWM(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetEwmGateCmd - * Description : Get the the clock gate state for EWM module - * This function will get the clock gate state for EWM moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetEwmGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC4_EWM(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableFtfClock - * Description : Enable the clock for FTF module - * This function enables the clock for FTF moudle. - * - *END**************************************************************************/ -void SIM_HAL_EnableFtfClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_FTF(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableFtfClock - * Description : Disable the clock for FTF module - * This function disables the clock for FTF moudle. - * - *END**************************************************************************/ -void SIM_HAL_DisableFtfClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_FTF(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtfGateCmd - * Description : Get the the clock gate state for FTF module - * This function will get the clock gate state for FTF moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetFtfGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC6_FTF(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableCrcClock - * Description : Enable the clock for CRC module - * This function enables the clock for CRC moudle. - * - *END**************************************************************************/ -void SIM_HAL_EnableCrcClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_CRC(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableCrcClock - * Description : Disable the clock for CRC module - * This function disables the clock for CRC moudle. - * - *END**************************************************************************/ -void SIM_HAL_DisableCrcClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_CRC(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetCrcGateCmd - * Description : Get the the clock gate state for CRC module - * This function will get the clock gate state for CRC moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetCrcGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC6_CRC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableAdcClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC5_ADC(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableAdcClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC5_ADC(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - retValue = SIM_BRD_SCGC5_ADC(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableCmpClock - * Description : Enable the clock for CMP module - * This function enables the clock for CMP moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableCmpClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC4_CMP(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableCmpClock - * Description : Disable the clock for CMP module - * This function disables the clock for CMP moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableCmpClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC4_CMP(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetCmpGateCmd - * Description : Get the the clock gate state for CMP module - * This function will get the clock gate state for CMP moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetCmpGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC4_CMP(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableDacClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_DAC0(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableDacClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_DAC0(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetDacGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - retValue = SIM_BRD_SCGC6_DAC0(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnablePdbClock - * Description : Enable the clock for PDB module - * This function enables the clock for PDB moudle - * - *END**************************************************************************/ -void SIM_HAL_EnablePdbClock(SIM_Type* base, uint32_t instance) -{ - switch(instance) - { - case 0: - SIM_BWR_SCGC6_PDB0(base, 1); - break; - case 1: - SIM_BWR_SCGC6_PDB1(base, 1); - break; - default: break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisablePdbClock - * Description : Disable the clock for PDB module - * This function disables the clock for PDB moudle - * - *END**************************************************************************/ -void SIM_HAL_DisablePdbClock(SIM_Type* base, uint32_t instance) -{ - switch(instance) - { - case 0: - SIM_BWR_SCGC6_PDB0(base, 0); - break; - case 1: - SIM_BWR_SCGC6_PDB1(base, 0); - break; - default: break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetPdbGateCmd - * Description : Get the the clock gate state for PDB module - * This function will get the clock gate state for PDB moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetPdbGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch(instance) - { - case 0: - retValue = SIM_BRD_SCGC6_PDB0(base); - break; - case 1: - retValue = SIM_BRD_SCGC6_PDB1(base); - break; - default: break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableFtmClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC6_FTM0(base, 1); - break; - case 1: - SIM_BWR_SCGC6_FTM1(base, 1); - break; - case 3: - SIM_BWR_SCGC6_FTM3(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableFtmClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC6_FTM0(base, 0); - break; - case 1: - SIM_BWR_SCGC6_FTM1(base, 0); - break; - case 3: - SIM_BWR_SCGC6_FTM3(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetFtmGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_SCGC6_FTM0(base); - break; - case 1: - retValue = SIM_BRD_SCGC6_FTM1(base); - break; - case 2: - retValue = false; - break; - case 3: - retValue = SIM_BRD_SCGC6_FTM3(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcxMuxSelChannely - * Description : ADC x (0-A, 1-B)channel y (6,7) Mux. - * Refer to RM for specific channel settings - * Selects ADCx MUX0's channel to ADCx channel y. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcxMuxSelChannely(SIM_Type* base, uint32_t instance, - uint8_t channel, uint8_t select) -{ - assert (instance<2); - assert (channel<8); - assert (channel>5); - switch(instance) - { - case 0: - switch(channel) - { - case 6: - SIM_BWR_ADCOPT_ADCACH6SEL(base, select); - break; - case 7: - SIM_BWR_ADCOPT_ADCACH7SEL(base, select); - break; - default: - break; - } - break; - case 1: - switch(channel) - { - case 6: - SIM_BWR_ADCOPT_ADCBCH6SEL(base, select); - break; - case 7: - SIM_BWR_ADCOPT_ADCBCH7SEL(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChOutSrcMode - * Description : Get FlexTimer x channel y output source select setting - * This function will get FlexTimer x channel y output source select - * setting. - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetAdcxMuxSelChannely(SIM_Type* base, uint32_t instance, uint8_t channel) -{ - assert (instance<2); - assert (channel<8); - assert (channel>5); - uint8_t retValue = (uint8_t) false; - switch(instance) - { - case 0: - switch(channel) - { - case 6: - retValue = (uint8_t)SIM_BRD_ADCOPT_ADCACH6SEL(base); - break; - case 7: - retValue = (uint8_t)SIM_BRD_ADCOPT_ADCACH7SEL(base); - break; - default: - retValue = (uint8_t) false; - break; - } - break; - case 3: - switch(channel) - { - case 6: - retValue = (uint8_t)SIM_BRD_ADCOPT_ADCBCH6SEL(base); - break; - case 7: - retValue = (uint8_t)SIM_BRD_ADCOPT_ADCBCH7SEL(base); - break; - default: - retValue = (uint8_t) false; - break; - } - break; - default: - retValue = (uint8_t) false; - break; - } - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetNanoedgeRegulator12SupStdbyControl - * Description : Nanoedge Regulator 1.2 V Supply Standby Control - * This function controls the standby mode of the 1.2 V supply from the nanoedge voltage regulator. - * 00 Nanoedge regulator 1.2 V supply placed in normal mode - * 01 Nanoedge regulator 1.2 V supply placed in standby mode. - * 10 Nanoedge regulator 1.2 V supply placed in normal mode and SR12STDBY is write protected until - * chip reset. - * 11 Nanoedge regulator 1.2 V supply placed in standby mode and SR12STDBY is write protected until - * chip reset. - * - *END**************************************************************************/ -void SIM_HAL_SetNanoedgeRegulator12SupStdbyControl(SIM_Type* base, uint8_t select) -{ - assert (select < 4); - SIM_BWR_PWRC_SR12STDBY(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetNanoedgeRegulator12SupStdbyControl - * Description : Get Nanoedge Regulator 1.2 V Supply Standby Control - * This function will get the standby mode of the 1.2 V supply from the nanoedge voltage regulator - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetNanoedgeRegulator12SupStdbyControl(SIM_Type* base) -{ - return (uint8_t)SIM_BRD_PWRC_SR12STDBY(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetNanoedgeRegulator27SupStdbyControl - * Description : Nanoedge Regulator 2.7 V Supply Standby Control - * This function controls the standby mode of the 2.7 V supply from the nanoedge voltage regulator. - * 00 Nanoedge regulator 2.7 V supply placed in normal mode - * 01 Nanoedge regulator 2.7 V supply placed in standby mode. - * 10 Nanoedge regulator 2.7 V supply placed in normal mode and SR27STDBY is write protected until - * chip reset. - * 11 Nanoedge regulator 2.7 V supply placed in standby mode and SR27STDBY is write protected until - * chip reset. - * - *END**************************************************************************/ -void SIM_HAL_SetNanoedgeRegulator27SupStdbyControl(SIM_Type* base, uint8_t select) -{ - assert (select < 4); - SIM_BWR_PWRC_SR12STDBY(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetNanoedgeRegulator27SupStdbyControl - * Description : Get Nanoedge Regulator 2.7 V Supply Standby Control - * This function will get the standby mode of the 2.7 V supply from the nanoedge voltage regulator - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetNanoedgeRegulator27SupStdbyControl(SIM_Type* base) -{ - return (uint8_t)SIM_BRD_PWRC_SR12STDBY(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetNanoedgeReg27n12SupPwrdwnControl - * Description : Nanoedge Regulator 2.7V and 1.2V Supply Powerdown Control - * This function controls the powerdown mode of the 2.7V and 1.2V supply from the nanoedge voltage regulator - * 00 Nanoedge regulator placed in normal mode. - * 01 Nanoedge regulator placed in powerdown mode. - * 10 Nanoedge regulator placed in normal mode and SRPDN is write protected until chip reset. - * 11 Nanoedge regulator placed in powerdown mode and SRPDN is write protected until chip reset. - * - *END**************************************************************************/ -void SIM_HAL_SetNanoedgeReg27n12SupPwrdwnControl(SIM_Type* base, uint8_t select) -{ - assert (select < 4); - SIM_BWR_PWRC_SRPDN(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetNanoedgeReg27n12SupPwrdwnControl - * Description : Get Nanoedge Regulator 2.7 V Supply Standby Control - * This function will get the standby mode of the 2.7 V supply from the nanoedge voltage regulator - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetNanoedgeReg27n12SupPwrdwnControl(SIM_Type* base) -{ - return (uint8_t)SIM_BRD_PWRC_SRPDN(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetWdogClkSrc - * Description : WDOG Clock Select - * This function selects the clock source of the WDOG2008 watchdog. - * 0 Internal 1 kHz clock is source to WDOG2008 - * 1 MCGIRCLK is source to WDOG2008 - * - *END**************************************************************************/ -void SIM_HAL_SetWdogClkSrc(SIM_Type* base, bool select) -{ - SIM_BWR_WDOGC_WDOGCLKS(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetWdogClkSrc - * Description : Get WDOG Clock setting - * This function will get the clock source of the WDOG2008 watchdog - * - *END**************************************************************************/ -bool SIM_HAL_GetWdogClkSrc(SIM_Type* base) -{ - return (bool)SIM_BRD_WDOGC_WDOGCLKS(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarAPittrigX - * Description : Synchronize XBARA's Input PIT Trigger X with fast clock - * This function controls the synchronizer between PIT trigger X and XBARA's input. - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarAPittrigX(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG0(base, 1); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG1(base, 1); - break; - case 2: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG2(base, 1); - break; - case 3: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG3(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarAPittrigX - * Description : Disable the synchronizer between PIT trigger X and XBARA's input - * This function Disables the synchronizer between PIT trigger X and XBARA's input - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarAPittrigX(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG0(base, 0); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG1(base, 0); - break; - case 2: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG2(base, 0); - break; - case 3: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG3(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarAPittrigXcmd - * Description : Get the synchronizer cmd between PIT trigger X and XBARA's input - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarAPittrigXcmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_MISCTRL2_SYNCXBARAPITTRIG0(base); - break; - case 1: - retValue = SIM_BRD_MISCTRL2_SYNCXBARAPITTRIG1(base); - break; - case 2: - retValue = SIM_BRD_MISCTRL2_SYNCXBARAPITTRIG2(base); - break; - case 3: - retValue = SIM_BRD_MISCTRL2_SYNCXBARAPITTRIG3(base); - break; - default: - retValue = false; - break; - } - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarBPittrigX - * Description : Synchronize XBARB's Input PIT Trigger X with fast clock - * This function controls the synchronizer between PIT trigger X and XBARB's input. - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarBPittrigX(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCXBARBPITTRIG0(base, 1); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCXBARBPITTRIG1(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarBPittrigX - * Description : Disable the synchronizer between PIT trigger X and XBARB's input - * This function Disables the synchronizer between PIT trigger X and XBARB's input - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarBPittrigX(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCXBARBPITTRIG0(base, 0); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCXBARBPITTRIG1(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarBPittrigXcmd - * Description : Get the synchronizer cmd between PIT trigger X and XBARB's input - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarBPittrigXcmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_MISCTRL2_SYNCXBARBPITTRIG0(base); - break; - case 1: - retValue = SIM_BRD_MISCTRL2_SYNCXBARBPITTRIG1(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarDac - * Description : Synchronize XBARA's output for DAC Hardware Trigger with flash/slow clock - * This function controls the synchronizer between XBARA's output and DAC hardware trigger. - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarDac(SIM_Type* base) -{ - SIM_BWR_MISCTRL2_SYNCDACHWTRIG(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarDac - * Description : Disable the synchronizer between XBARA's output and DAC hardware trigger - * This function Disables the synchronizer between XBARA's output and DAC hardware trigger - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarDac(SIM_Type* base) -{ - SIM_BWR_MISCTRL2_SYNCDACHWTRIG(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarDaccmd - * Description : Get the synchronizer cmd between XBARA's output and DAC hardware trigger - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarDaccmd(SIM_Type* base) -{ - return (bool)SIM_BRD_MISCTRL2_SYNCDACHWTRIG(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarEwmin - * Description : Enable the synchronizer between XBARA's output and EWM's ewm_in - * This function enables the synchronizer between XBARA's output and EWM's ewm_in - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarEwmin(SIM_Type* base) -{ - SIM_BWR_MISCTRL2_SYNCEWMIN(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarEwmin - * Description : Disable the synchronizer between XBARA's output and EWM's ewm_in - * This function Disables the synchronizer between XBARA's output and EWM's ewm_in - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarEwmin(SIM_Type* base) -{ - SIM_BWR_MISCTRL2_SYNCEWMIN(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarEwmincmd - * Description : Get the synchronizer cmd between XBARA's output and EWM's ewm_in - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarEwmincmd(SIM_Type* base) -{ - return (bool)SIM_BRD_MISCTRL2_SYNCEWMIN(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarCmpX - * Description : Enable the the synchronizer between XBARA's output and CMP3's sample/window input - * This function enables the the synchronizer between XBARA's output and CMP3's sample/window input - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarCmpX(SIM_Type* base, uint32_t instance) -{ - assert (instance < CMP_INSTANCE_COUNT); - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCCMP0SAMPLEWIN(base, 1); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCCMP1SAMPLEWIN(base, 1); - break; - case 2: - SIM_BWR_MISCTRL2_SYNCCMP2SAMPLEWIN(base, 1); - break; - case 3: - SIM_BWR_MISCTRL2_SYNCCMP3SAMPLEWIN(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarCmpX - * Description : Disable the synchronizer between XBARA's output and CMP3's sample/window input - * This function Disables the synchronizer between XBARA's output and CMP3's sample/window input - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarCmpX(SIM_Type* base, uint32_t instance) -{ - assert (instance < CMP_INSTANCE_COUNT); - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCCMP0SAMPLEWIN(base, 0); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCCMP1SAMPLEWIN(base, 0); - break; - case 2: - SIM_BWR_MISCTRL2_SYNCCMP2SAMPLEWIN(base, 0); - break; - case 3: - SIM_BWR_MISCTRL2_SYNCCMP3SAMPLEWIN(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarCmpXcmd - * Description : Get the synchronizer cmd between XBARA's output and CMP3's sample/window input - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarCmpXcmd(SIM_Type* base, uint32_t instance) -{ - assert (instance < CMP_INSTANCE_COUNT); - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_MISCTRL2_SYNCCMP0SAMPLEWIN(base); - break; - case 1: - retValue = SIM_BRD_MISCTRL2_SYNCCMP1SAMPLEWIN(base); - break; - case 2: - retValue = SIM_BRD_MISCTRL2_SYNCCMP2SAMPLEWIN(base); - break; - case 3: - retValue = SIM_BRD_MISCTRL2_SYNCCMP3SAMPLEWIN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetCmpWinxSrc - * Description : Set CMP Sample/Window Input X Source - * This function controls the sample/window source of CMP module - * - *END**************************************************************************/ -void SIM_HAL_SetCmpWinxSrc(SIM_Type* base, uint32_t instance, - sim_cmp_win_in_src select) -{ - assert (instance < CMP_INSTANCE_COUNT); - switch (instance) - { - case 0: - SIM_BWR_MISCTRL_CMPWIN0SRC(base, select); - break; - case 1: - SIM_BWR_MISCTRL_CMPWIN1SRC(base, select); - break; - case 2: - SIM_BWR_MISCTRL_CMPWIN2SRC(base, select); - break; - case 3: - SIM_BWR_MISCTRL_CMPWIN3SRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetCmpWinxSrc - * Description : Get CMP Sample/Window Input X Source - * This function will get the sample/window source of CMP module - * - *END**************************************************************************/ -sim_cmp_win_in_src SIM_HAL_GetCmpWinxSrc(SIM_Type* base, uint32_t instance) -{ - assert (instance < CMP_INSTANCE_COUNT); - sim_cmp_win_in_src retValue = (sim_cmp_win_in_src)0; - switch (instance) - { - case 0: - retValue = (sim_cmp_win_in_src)SIM_BRD_MISCTRL_CMPWIN0SRC(base); - break; - case 1: - retValue = (sim_cmp_win_in_src)SIM_BRD_MISCTRL_CMPWIN1SRC(base); - break; - case 2: - retValue = (sim_cmp_win_in_src)SIM_BRD_MISCTRL_CMPWIN2SRC(base); - break; - case 3: - retValue = (sim_cmp_win_in_src)SIM_BRD_MISCTRL_CMPWIN3SRC(base); - break; - default: - break; - } - - return retValue; -} - - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetEwmInSrc - * Description : Set EWM_IN source setting - * This function controls the ewm_in source of EWM module - * - *END**************************************************************************/ -void SIM_HAL_SetEwmInSrc(SIM_Type* base, sim_ewm_in_src select) -{ - SIM_BWR_MISCTRL_EWMINSRC(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetEwmInSrc - * Description : Get EWM_IN source setting - * This function will get the ewm_in source of EWM module - * - *END**************************************************************************/ -sim_ewm_in_src SIM_HAL_GetEwmInSrc(SIM_Type* base) -{ - return (sim_ewm_in_src)SIM_BRD_MISCTRL_EWMINSRC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetDacHwTrigSrc - * Description : Set DAC x Hardware trigger source setting - * This function will select the DAC0 Hardware Trigger Input Source - * - *END**************************************************************************/ -void SIM_HAL_SetDacHwTrigSrc(SIM_Type* base,sim_dac_hw_trg_sel select) -{ - SIM_BWR_MISCTRL_DACTRIGSRC(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetDacHwTrigSrc - * Description : Get DAC x Hardware trigger source setting - * This function will get the DAC0 Hardware Trigger Input Source - * - *END**************************************************************************/ -sim_dac_hw_trg_sel SIM_HAL_GetDacHwTrigSrc(SIM_Type* base, uint32_t instance) -{ - return (sim_dac_hw_trg_sel)SIM_BRD_MISCTRL_DACTRIGSRC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT9_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT9_FTM1CLKSEL(base, select); - break; - case 3: - SIM_BWR_SOPT9_FTM3CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT9_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT9_FTM1CLKSEL(base); - break; - case 3: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT9_FTM3CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT9_FTM1ICH0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT9_FTM1ICH1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)false; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT9_FTM1ICH0SRC(base); - break; - case 1: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT9_FTM1ICH1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChOutSrcMode - * Description : FlexTimer x channel y output source select setting. - * This function will select FlexTimer x channel y output source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChOutSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_out_src_t select) -{ - switch(instance) - { - case 0: - switch(channel) - { - case 0: - SIM_BWR_SOPT8_FTM0OCH0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT8_FTM0OCH1SRC(base, select); - break; - case 2: - SIM_BWR_SOPT8_FTM0OCH2SRC(base, select); - break; - case 3: - SIM_BWR_SOPT8_FTM0OCH3SRC(base, select); - break; - case 4: - SIM_BWR_SOPT8_FTM0OCH4SRC(base, select); - break; - case 5: - SIM_BWR_SOPT8_FTM0OCH5SRC(base, select); - break; - case 6: - SIM_BWR_SOPT8_FTM0OCH6SRC(base, select); - break; - case 7: - SIM_BWR_SOPT8_FTM0OCH7SRC(base, select); - break; - default: - break; - } - break; - case 3: - switch(channel) - { - case 0: - SIM_BWR_SOPT8_FTM3OCH0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT8_FTM3OCH1SRC(base, select); - break; - case 2: - SIM_BWR_SOPT8_FTM3OCH2SRC(base, select); - break; - case 3: - SIM_BWR_SOPT8_FTM3OCH3SRC(base, select); - break; - case 4: - SIM_BWR_SOPT8_FTM3OCH4SRC(base, select); - break; - case 5: - SIM_BWR_SOPT8_FTM3OCH5SRC(base, select); - break; - case 6: - SIM_BWR_SOPT8_FTM3OCH6SRC(base, select); - break; - case 7: - SIM_BWR_SOPT8_FTM3OCH7SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChOutSrcMode - * Description : Get FlexTimer x channel y output source select setting - * This function will get FlexTimer x channel y output source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_out_src_t SIM_HAL_GetFtmChOutSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_out_src_t retValue = (sim_ftm_ch_out_src_t) false; - switch(instance) - { - case 0: - switch(channel) - { - case 0: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH0SRC(base); - break; - case 1: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH1SRC(base); - break; - case 2: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH2SRC(base); - break; - case 3: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH3SRC(base); - break; - case 4: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH4SRC(base); - break; - case 5: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH5SRC(base); - break; - case 6: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH6SRC(base); - break; - case 7: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH7SRC(base); - break; - default: - retValue = (sim_ftm_ch_out_src_t) false; - break; - } - break; - case 3: - switch(channel) - { - case 0: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH0SRC(base); - break; - case 1: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH1SRC(base); - break; - case 2: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH2SRC(base); - break; - case 3: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH3SRC(base); - break; - case 4: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH4SRC(base); - break; - case 5: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH5SRC(base); - break; - case 6: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH6SRC(base); - break; - case 7: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH7SRC(base); - break; - default: - retValue = (sim_ftm_ch_out_src_t) false; - break; - } - break; - default: - retValue = (sim_ftm_ch_out_src_t) false; - break; - } - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmCarrierFreqCmd - * Description : Set FTMxCFSELBIT - * This function sets FlexTimer x carrier frequency selection software configuration setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmCarrierFreqCmd(SIM_Type* base, uint32_t instance, bool ftmcarrierfreqsrc) -{ - assert (instance < FTM_INSTANCE_COUNT); - switch(instance) - { - case 0: - SIM_BWR_SOPT8_FTM0CFSEL(base,ftmcarrierfreqsrc); - break; - case 3: - SIM_BWR_SOPT8_FTM3CFSEL(base,ftmcarrierfreqsrc); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmCarrierFreqCmd - * Description : Get FlexTimer x carrier frequency selection software configuration setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetFtmCarrierFreqCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - assert (instance < FTM_INSTANCE_COUNT); - switch(instance) - { - case 0: - retValue = SIM_BRD_SOPT8_FTM0CFSEL(base); - break; - case 3: - retValue = SIM_BRD_SOPT8_FTM3CFSEL(base); - break; - default: - retValue = false; - break; - } - return retValue; -} -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmSyncCmd - * Description : Set FTMxSYNCBIT - * This function sets FlexTimer x hardware trigger 0 software synchronization. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmSyncCmd(SIM_Type* base, uint32_t instance, bool sync) -{ - assert (instance < FTM_INSTANCE_COUNT); - if (sync) - { - SIM_SET_SOPT8(base, (1U< -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type* base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type* base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableDmaClock - * Description : Enable the clock for DMA module - * This function enables the clock for DMA moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableDmaClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC7_DMA(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableDmaClock - * Description : Disable the clock for DMA module - * This function disables the clock for DMA moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableDmaClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC7_DMA(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetDmaGateCmd - * Description : Get the the clock gate state for DMA module - * This function will get the clock gate state for DMA moudle - * - *END**************************************************************************/ -bool SIM_HAL_GetDmaGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC7_DMA(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableDmamuxClock - * Description : Enable the clock for DMAMUX module - * This function enables the clock for DMAMUX moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableDmamuxClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_DMAMUX(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableDmamuxClock - * Description : Disable the clock for DMAMUX module - * This function disables the clock for DMAMUX moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableDmamuxClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_DMAMUX(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetDmamuxGateCmd - * Description : Get the the clock gate state for DMAMUX module - * This function will get the clock gate state for DMAMUX moudle - * - *END**************************************************************************/ -bool SIM_HAL_GetDmamuxGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC6_DMAMUX(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void SIM_HAL_EnablePortClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC5_PORTA(base, 1); - break; - case 1: - SIM_BWR_SCGC5_PORTB(base, 1); - break; - case 2: - SIM_BWR_SCGC5_PORTC(base, 1); - break; - case 3: - SIM_BWR_SCGC5_PORTD(base, 1); - break; - case 4: - SIM_BWR_SCGC5_PORTE(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void SIM_HAL_DisablePortClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC5_PORTA(base, 0); - break; - case 1: - SIM_BWR_SCGC5_PORTB(base, 0); - break; - case 2: - SIM_BWR_SCGC5_PORTC(base, 0); - break; - case 3: - SIM_BWR_SCGC5_PORTD(base, 0); - break; - case 4: - SIM_BWR_SCGC5_PORTE(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetPortGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_SCGC5_PORTA(base); - break; - case 1: - retValue = SIM_BRD_SCGC5_PORTB(base); - break; - case 2: - retValue = SIM_BRD_SCGC5_PORTC(base); - break; - case 3: - retValue = SIM_BRD_SCGC5_PORTD(base); - break; - case 4: - retValue = SIM_BRD_SCGC5_PORTE(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableEwmClock - * Description : Enable the clock for EWM module - * This function enables the clock for EWM moudle. - * - *END**************************************************************************/ -void SIM_HAL_EnableEwmClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC4_EWM(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableEwmClock - * Description : Disable the clock for EWM modul - * This function disables the clock for EWM moudle. - * - *END**************************************************************************/ -void SIM_HAL_DisableEwmClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC4_EWM(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetEwmGateCmd - * Description : Get the the clock gate state for EWM module - * This function will get the clock gate state for EWM moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetEwmGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC4_EWM(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableFtfClock - * Description : Enable the clock for FTF module - * This function enables the clock for FTF moudle. - * - *END**************************************************************************/ -void SIM_HAL_EnableFtfClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_FTF(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableFtfClock - * Description : Disable the clock for FTF module - * This function disables the clock for FTF moudle. - * - *END**************************************************************************/ -void SIM_HAL_DisableFtfClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_FTF(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtfGateCmd - * Description : Get the the clock gate state for FTF module - * This function will get the clock gate state for FTF moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetFtfGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC6_FTF(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableCrcClock - * Description : Enable the clock for CRC module - * This function enables the clock for CRC moudle. - * - *END**************************************************************************/ -void SIM_HAL_EnableCrcClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_CRC(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableCrcClock - * Description : Disable the clock for CRC module - * This function disables the clock for CRC moudle. - * - *END**************************************************************************/ -void SIM_HAL_DisableCrcClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_CRC(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetCrcGateCmd - * Description : Get the the clock gate state for CRC module - * This function will get the clock gate state for CRC moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetCrcGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC6_CRC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableAdcClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC5_ADC(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableAdcClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC5_ADC(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - retValue = SIM_BRD_SCGC5_ADC(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableCmpClock - * Description : Enable the clock for CMP module - * This function enables the clock for CMP moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableCmpClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC4_CMP(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableCmpClock - * Description : Disable the clock for CMP module - * This function disables the clock for CMP moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableCmpClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC4_CMP(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetCmpGateCmd - * Description : Get the the clock gate state for CMP module - * This function will get the clock gate state for CMP moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetCmpGateCmd(SIM_Type* base, uint32_t instance) -{ - return SIM_BRD_SCGC4_CMP(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableDacClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_DAC0(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableDacClock(SIM_Type* base, uint32_t instance) -{ - SIM_BWR_SCGC6_DAC0(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetDacGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - retValue = SIM_BRD_SCGC6_DAC0(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnablePdbClock - * Description : Enable the clock for PDB module - * This function enables the clock for PDB moudle - * - *END**************************************************************************/ -void SIM_HAL_EnablePdbClock(SIM_Type* base, uint32_t instance) -{ - switch(instance) - { - case 0: - SIM_BWR_SCGC6_PDB0(base, 1); - break; - case 1: - SIM_BWR_SCGC6_PDB1(base, 1); - break; - default: break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisablePdbClock - * Description : Disable the clock for PDB module - * This function disables the clock for PDB moudle - * - *END**************************************************************************/ -void SIM_HAL_DisablePdbClock(SIM_Type* base, uint32_t instance) -{ - switch(instance) - { - case 0: - SIM_BWR_SCGC6_PDB0(base, 0); - break; - case 1: - SIM_BWR_SCGC6_PDB1(base, 0); - break; - default: break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetPdbGateCmd - * Description : Get the the clock gate state for PDB module - * This function will get the clock gate state for PDB moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetPdbGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch(instance) - { - case 0: - retValue = SIM_BRD_SCGC6_PDB0(base); - break; - case 1: - retValue = SIM_BRD_SCGC6_PDB1(base); - break; - default: break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM moudle - * - *END**************************************************************************/ -void SIM_HAL_EnableFtmClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC6_FTM0(base, 1); - break; - case 1: - SIM_BWR_SCGC6_FTM1(base, 1); - break; - case 3: - SIM_BWR_SCGC6_FTM3(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM moudle - * - *END**************************************************************************/ -void SIM_HAL_DisableFtmClock(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_SCGC6_FTM0(base, 0); - break; - case 1: - SIM_BWR_SCGC6_FTM1(base, 0); - break; - case 3: - SIM_BWR_SCGC6_FTM3(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM moudle. - * - *END**************************************************************************/ -bool SIM_HAL_GetFtmGateCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_SCGC6_FTM0(base); - break; - case 1: - retValue = SIM_BRD_SCGC6_FTM1(base); - break; - case 2: - retValue = false; - break; - case 3: - retValue = SIM_BRD_SCGC6_FTM3(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcxMuxSelChannely - * Description : ADC x (0-A, 1-B)channel y (6,7) Mux. - * Refer to RM for specific channel settings - * Selects ADCx MUX0's channel to ADCx channel y. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcxMuxSelChannely(SIM_Type* base, uint32_t instance, - uint8_t channel, uint8_t select) -{ - assert (instance<2); - assert (channel<8); - assert (channel>5); - switch(instance) - { - case 0: - switch(channel) - { - case 6: - SIM_BWR_ADCOPT_ADCACH6SEL(base, select); - break; - case 7: - SIM_BWR_ADCOPT_ADCACH7SEL(base, select); - break; - default: - break; - } - break; - case 1: - switch(channel) - { - case 6: - SIM_BWR_ADCOPT_ADCBCH6SEL(base, select); - break; - case 7: - SIM_BWR_ADCOPT_ADCBCH7SEL(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChOutSrcMode - * Description : Get FlexTimer x channel y output source select setting - * This function will get FlexTimer x channel y output source select - * setting. - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetAdcxMuxSelChannely(SIM_Type* base, uint32_t instance, uint8_t channel) -{ - assert (instance<2); - assert (channel<8); - assert (channel>5); - uint8_t retValue = (uint8_t) false; - switch(instance) - { - case 0: - switch(channel) - { - case 6: - retValue = (uint8_t)SIM_BRD_ADCOPT_ADCACH6SEL(base); - break; - case 7: - retValue = (uint8_t)SIM_BRD_ADCOPT_ADCACH7SEL(base); - break; - default: - retValue = (uint8_t) false; - break; - } - break; - case 3: - switch(channel) - { - case 6: - retValue = (uint8_t)SIM_BRD_ADCOPT_ADCBCH6SEL(base); - break; - case 7: - retValue = (uint8_t)SIM_BRD_ADCOPT_ADCBCH7SEL(base); - break; - default: - retValue = (uint8_t) false; - break; - } - break; - default: - retValue = (uint8_t) false; - break; - } - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetNanoedgeRegulator12SupStdbyControl - * Description : Nanoedge Regulator 1.2 V Supply Standby Control - * This function controls the standby mode of the 1.2 V supply from the nanoedge voltage regulator. - * 00 Nanoedge regulator 1.2 V supply placed in normal mode - * 01 Nanoedge regulator 1.2 V supply placed in standby mode. - * 10 Nanoedge regulator 1.2 V supply placed in normal mode and SR12STDBY is write protected until - * chip reset. - * 11 Nanoedge regulator 1.2 V supply placed in standby mode and SR12STDBY is write protected until - * chip reset. - * - *END**************************************************************************/ -void SIM_HAL_SetNanoedgeRegulator12SupStdbyControl(SIM_Type* base, uint8_t select) -{ - assert (select < 4); - SIM_BWR_PWRC_SR12STDBY(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetNanoedgeRegulator12SupStdbyControl - * Description : Get Nanoedge Regulator 1.2 V Supply Standby Control - * This function will get the standby mode of the 1.2 V supply from the nanoedge voltage regulator - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetNanoedgeRegulator12SupStdbyControl(SIM_Type* base) -{ - return (uint8_t)SIM_BRD_PWRC_SR12STDBY(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetNanoedgeRegulator27SupStdbyControl - * Description : Nanoedge Regulator 2.7 V Supply Standby Control - * This function controls the standby mode of the 2.7 V supply from the nanoedge voltage regulator. - * 00 Nanoedge regulator 2.7 V supply placed in normal mode - * 01 Nanoedge regulator 2.7 V supply placed in standby mode. - * 10 Nanoedge regulator 2.7 V supply placed in normal mode and SR27STDBY is write protected until - * chip reset. - * 11 Nanoedge regulator 2.7 V supply placed in standby mode and SR27STDBY is write protected until - * chip reset. - * - *END**************************************************************************/ -void SIM_HAL_SetNanoedgeRegulator27SupStdbyControl(SIM_Type* base, uint8_t select) -{ - assert (select < 4); - SIM_BWR_PWRC_SR12STDBY(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetNanoedgeRegulator27SupStdbyControl - * Description : Get Nanoedge Regulator 2.7 V Supply Standby Control - * This function will get the standby mode of the 2.7 V supply from the nanoedge voltage regulator - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetNanoedgeRegulator27SupStdbyControl(SIM_Type* base) -{ - return (uint8_t)SIM_BRD_PWRC_SR12STDBY(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetNanoedgeReg27n12SupPwrdwnControl - * Description : Nanoedge Regulator 2.7V and 1.2V Supply Powerdown Control - * This function controls the powerdown mode of the 2.7V and 1.2V supply from the nanoedge voltage regulator - * 00 Nanoedge regulator placed in normal mode. - * 01 Nanoedge regulator placed in powerdown mode. - * 10 Nanoedge regulator placed in normal mode and SRPDN is write protected until chip reset. - * 11 Nanoedge regulator placed in powerdown mode and SRPDN is write protected until chip reset. - * - *END**************************************************************************/ -void SIM_HAL_SetNanoedgeReg27n12SupPwrdwnControl(SIM_Type* base, uint8_t select) -{ - assert (select < 4); - SIM_BWR_PWRC_SRPDN(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetNanoedgeReg27n12SupPwrdwnControl - * Description : Get Nanoedge Regulator 2.7 V Supply Standby Control - * This function will get the standby mode of the 2.7 V supply from the nanoedge voltage regulator - * - *END**************************************************************************/ -uint8_t SIM_HAL_GetNanoedgeReg27n12SupPwrdwnControl(SIM_Type* base) -{ - return (uint8_t)SIM_BRD_PWRC_SRPDN(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetWdogClkSrc - * Description : WDOG Clock Select - * This function selects the clock source of the WDOG2008 watchdog. - * 0 Internal 1 kHz clock is source to WDOG2008 - * 1 MCGIRCLK is source to WDOG2008 - * - *END**************************************************************************/ -void SIM_HAL_SetWdogClkSrc(SIM_Type* base, bool select) -{ - SIM_BWR_WDOGC_WDOGCLKS(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetWdogClkSrc - * Description : Get WDOG Clock setting - * This function will get the clock source of the WDOG2008 watchdog - * - *END**************************************************************************/ -bool SIM_HAL_GetWdogClkSrc(SIM_Type* base) -{ - return (bool)SIM_BRD_WDOGC_WDOGCLKS(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarAPittrigX - * Description : Synchronize XBARA's Input PIT Trigger X with fast clock - * This function controls the synchronizer between PIT trigger X and XBARA's input. - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarAPittrigX(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG0(base, 1); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG1(base, 1); - break; - case 2: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG2(base, 1); - break; - case 3: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG3(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarAPittrigX - * Description : Disable the synchronizer between PIT trigger X and XBARA's input - * This function Disables the synchronizer between PIT trigger X and XBARA's input - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarAPittrigX(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG0(base, 0); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG1(base, 0); - break; - case 2: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG2(base, 0); - break; - case 3: - SIM_BWR_MISCTRL2_SYNCXBARAPITTRIG3(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarAPittrigXcmd - * Description : Get the synchronizer cmd between PIT trigger X and XBARA's input - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarAPittrigXcmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_MISCTRL2_SYNCXBARAPITTRIG0(base); - break; - case 1: - retValue = SIM_BRD_MISCTRL2_SYNCXBARAPITTRIG1(base); - break; - case 2: - retValue = SIM_BRD_MISCTRL2_SYNCXBARAPITTRIG2(base); - break; - case 3: - retValue = SIM_BRD_MISCTRL2_SYNCXBARAPITTRIG3(base); - break; - default: - retValue = false; - break; - } - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarBPittrigX - * Description : Synchronize XBARB's Input PIT Trigger X with fast clock - * This function controls the synchronizer between PIT trigger X and XBARB's input. - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarBPittrigX(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCXBARBPITTRIG0(base, 1); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCXBARBPITTRIG1(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarBPittrigX - * Description : Disable the synchronizer between PIT trigger X and XBARB's input - * This function Disables the synchronizer between PIT trigger X and XBARB's input - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarBPittrigX(SIM_Type* base, uint32_t instance) -{ - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCXBARBPITTRIG0(base, 0); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCXBARBPITTRIG1(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarBPittrigXcmd - * Description : Get the synchronizer cmd between PIT trigger X and XBARB's input - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarBPittrigXcmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_MISCTRL2_SYNCXBARBPITTRIG0(base); - break; - case 1: - retValue = SIM_BRD_MISCTRL2_SYNCXBARBPITTRIG1(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarDac - * Description : Synchronize XBARA's output for DAC Hardware Trigger with flash/slow clock - * This function controls the synchronizer between XBARA's output and DAC hardware trigger. - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarDac(SIM_Type* base) -{ - SIM_BWR_MISCTRL2_SYNCDACHWTRIG(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarDac - * Description : Disable the synchronizer between XBARA's output and DAC hardware trigger - * This function Disables the synchronizer between XBARA's output and DAC hardware trigger - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarDac(SIM_Type* base) -{ - SIM_BWR_MISCTRL2_SYNCDACHWTRIG(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarDaccmd - * Description : Get the synchronizer cmd between XBARA's output and DAC hardware trigger - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarDaccmd(SIM_Type* base) -{ - return (bool)SIM_BRD_MISCTRL2_SYNCDACHWTRIG(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarEwmin - * Description : Enable the synchronizer between XBARA's output and EWM's ewm_in - * This function enables the synchronizer between XBARA's output and EWM's ewm_in - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarEwmin(SIM_Type* base) -{ - SIM_BWR_MISCTRL2_SYNCEWMIN(base, 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarEwmin - * Description : Disable the synchronizer between XBARA's output and EWM's ewm_in - * This function Disables the synchronizer between XBARA's output and EWM's ewm_in - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarEwmin(SIM_Type* base) -{ - SIM_BWR_MISCTRL2_SYNCEWMIN(base, 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarEwmincmd - * Description : Get the synchronizer cmd between XBARA's output and EWM's ewm_in - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarEwmincmd(SIM_Type* base) -{ - return (bool)SIM_BRD_MISCTRL2_SYNCEWMIN(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableSyncXbarCmpX - * Description : Enable the the synchronizer between XBARA's output and CMP3's sample/window input - * This function enables the the synchronizer between XBARA's output and CMP3's sample/window input - * - *END**************************************************************************/ -void SIM_HAL_EnableSyncXbarCmpX(SIM_Type* base, uint32_t instance) -{ - assert (instance < CMP_INSTANCE_COUNT); - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCCMP0SAMPLEWIN(base, 1); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCCMP1SAMPLEWIN(base, 1); - break; - case 2: - SIM_BWR_MISCTRL2_SYNCCMP2SAMPLEWIN(base, 1); - break; - case 3: - SIM_BWR_MISCTRL2_SYNCCMP3SAMPLEWIN(base, 1); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableSyncXbarCmpX - * Description : Disable the synchronizer between XBARA's output and CMP3's sample/window input - * This function Disables the synchronizer between XBARA's output and CMP3's sample/window input - * - *END**************************************************************************/ -void SIM_HAL_DisableSyncXbarCmpX(SIM_Type* base, uint32_t instance) -{ - assert (instance < CMP_INSTANCE_COUNT); - switch (instance) - { - case 0: - SIM_BWR_MISCTRL2_SYNCCMP0SAMPLEWIN(base, 0); - break; - case 1: - SIM_BWR_MISCTRL2_SYNCCMP1SAMPLEWIN(base, 0); - break; - case 2: - SIM_BWR_MISCTRL2_SYNCCMP2SAMPLEWIN(base, 0); - break; - case 3: - SIM_BWR_MISCTRL2_SYNCCMP3SAMPLEWIN(base, 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetSyncXbarCmpXcmd - * Description : Get the synchronizer cmd between XBARA's output and CMP3's sample/window input - * - *END**************************************************************************/ -bool SIM_HAL_GetSyncXbarCmpXcmd(SIM_Type* base, uint32_t instance) -{ - assert (instance < CMP_INSTANCE_COUNT); - bool retValue = false; - - switch (instance) - { - case 0: - retValue = SIM_BRD_MISCTRL2_SYNCCMP0SAMPLEWIN(base); - break; - case 1: - retValue = SIM_BRD_MISCTRL2_SYNCCMP1SAMPLEWIN(base); - break; - case 2: - retValue = SIM_BRD_MISCTRL2_SYNCCMP2SAMPLEWIN(base); - break; - case 3: - retValue = SIM_BRD_MISCTRL2_SYNCCMP3SAMPLEWIN(base); - break; - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetCmpWinxSrc - * Description : Set CMP Sample/Window Input X Source - * This function controls the sample/window source of CMP module - * - *END**************************************************************************/ -void SIM_HAL_SetCmpWinxSrc(SIM_Type* base, uint32_t instance, - sim_cmp_win_in_src select) -{ - assert (instance < CMP_INSTANCE_COUNT); - switch (instance) - { - case 0: - SIM_BWR_MISCTRL_CMPWIN0SRC(base, select); - break; - case 1: - SIM_BWR_MISCTRL_CMPWIN1SRC(base, select); - break; - case 2: - SIM_BWR_MISCTRL_CMPWIN2SRC(base, select); - break; - case 3: - SIM_BWR_MISCTRL_CMPWIN3SRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetCmpWinxSrc - * Description : Get CMP Sample/Window Input X Source - * This function will get the sample/window source of CMP module - * - *END**************************************************************************/ -sim_cmp_win_in_src SIM_HAL_GetCmpWinxSrc(SIM_Type* base, uint32_t instance) -{ - assert (instance < CMP_INSTANCE_COUNT); - sim_cmp_win_in_src retValue = (sim_cmp_win_in_src)0; - switch (instance) - { - case 0: - retValue = (sim_cmp_win_in_src)SIM_BRD_MISCTRL_CMPWIN0SRC(base); - break; - case 1: - retValue = (sim_cmp_win_in_src)SIM_BRD_MISCTRL_CMPWIN1SRC(base); - break; - case 2: - retValue = (sim_cmp_win_in_src)SIM_BRD_MISCTRL_CMPWIN2SRC(base); - break; - case 3: - retValue = (sim_cmp_win_in_src)SIM_BRD_MISCTRL_CMPWIN3SRC(base); - break; - default: - break; - } - - return retValue; -} - - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetEwmInSrc - * Description : Set EWM_IN source setting - * This function controls the ewm_in source of EWM module - * - *END**************************************************************************/ -void SIM_HAL_SetEwmInSrc(SIM_Type* base, sim_ewm_in_src select) -{ - SIM_BWR_MISCTRL_EWMINSRC(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetEwmInSrc - * Description : Get EWM_IN source setting - * This function will get the ewm_in source of EWM module - * - *END**************************************************************************/ -sim_ewm_in_src SIM_HAL_GetEwmInSrc(SIM_Type* base) -{ - return (sim_ewm_in_src)SIM_BRD_MISCTRL_EWMINSRC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetDacHwTrigSrc - * Description : Set DAC x Hardware trigger source setting - * This function will select the DAC0 Hardware Trigger Input Source - * - *END**************************************************************************/ -void SIM_HAL_SetDacHwTrigSrc(SIM_Type* base,sim_dac_hw_trg_sel select) -{ - SIM_BWR_MISCTRL_DACTRIGSRC(base, select); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetDacHwTrigSrc - * Description : Get DAC x Hardware trigger source setting - * This function will get the DAC0 Hardware Trigger Input Source - * - *END**************************************************************************/ -sim_dac_hw_trg_sel SIM_HAL_GetDacHwTrigSrc(SIM_Type* base, uint32_t instance) -{ - return (sim_dac_hw_trg_sel)SIM_BRD_MISCTRL_DACTRIGSRC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT9_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT9_FTM1CLKSEL(base, select); - break; - case 3: - SIM_BWR_SOPT9_FTM3CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT9_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT9_FTM1CLKSEL(base); - break; - case 3: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT9_FTM3CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT9_FTM1ICH0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT9_FTM1ICH1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)false; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT9_FTM1ICH0SRC(base); - break; - case 1: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT9_FTM1ICH1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChOutSrcMode - * Description : FlexTimer x channel y output source select setting. - * This function will select FlexTimer x channel y output source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChOutSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_out_src_t select) -{ - switch(instance) - { - case 0: - switch(channel) - { - case 0: - SIM_BWR_SOPT8_FTM0OCH0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT8_FTM0OCH1SRC(base, select); - break; - case 2: - SIM_BWR_SOPT8_FTM0OCH2SRC(base, select); - break; - case 3: - SIM_BWR_SOPT8_FTM0OCH3SRC(base, select); - break; - case 4: - SIM_BWR_SOPT8_FTM0OCH4SRC(base, select); - break; - case 5: - SIM_BWR_SOPT8_FTM0OCH5SRC(base, select); - break; - case 6: - SIM_BWR_SOPT8_FTM0OCH6SRC(base, select); - break; - case 7: - SIM_BWR_SOPT8_FTM0OCH7SRC(base, select); - break; - default: - break; - } - break; - case 3: - switch(channel) - { - case 0: - SIM_BWR_SOPT8_FTM3OCH0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT8_FTM3OCH1SRC(base, select); - break; - case 2: - SIM_BWR_SOPT8_FTM3OCH2SRC(base, select); - break; - case 3: - SIM_BWR_SOPT8_FTM3OCH3SRC(base, select); - break; - case 4: - SIM_BWR_SOPT8_FTM3OCH4SRC(base, select); - break; - case 5: - SIM_BWR_SOPT8_FTM3OCH5SRC(base, select); - break; - case 6: - SIM_BWR_SOPT8_FTM3OCH6SRC(base, select); - break; - case 7: - SIM_BWR_SOPT8_FTM3OCH7SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChOutSrcMode - * Description : Get FlexTimer x channel y output source select setting - * This function will get FlexTimer x channel y output source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_out_src_t SIM_HAL_GetFtmChOutSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_out_src_t retValue = (sim_ftm_ch_out_src_t) false; - switch(instance) - { - case 0: - switch(channel) - { - case 0: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH0SRC(base); - break; - case 1: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH1SRC(base); - break; - case 2: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH2SRC(base); - break; - case 3: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH3SRC(base); - break; - case 4: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH4SRC(base); - break; - case 5: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH5SRC(base); - break; - case 6: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH6SRC(base); - break; - case 7: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM0OCH7SRC(base); - break; - default: - retValue = (sim_ftm_ch_out_src_t) false; - break; - } - break; - case 3: - switch(channel) - { - case 0: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH0SRC(base); - break; - case 1: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH1SRC(base); - break; - case 2: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH2SRC(base); - break; - case 3: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH3SRC(base); - break; - case 4: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH4SRC(base); - break; - case 5: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH5SRC(base); - break; - case 6: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH6SRC(base); - break; - case 7: - retValue = (sim_ftm_ch_out_src_t)SIM_BRD_SOPT8_FTM3OCH7SRC(base); - break; - default: - retValue = (sim_ftm_ch_out_src_t) false; - break; - } - break; - default: - retValue = (sim_ftm_ch_out_src_t) false; - break; - } - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmCarrierFreqCmd - * Description : Set FTMxCFSELBIT - * This function sets FlexTimer x carrier frequency selection software configuration setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmCarrierFreqCmd(SIM_Type* base, uint32_t instance, bool ftmcarrierfreqsrc) -{ - assert (instance < FTM_INSTANCE_COUNT); - switch(instance) - { - case 0: - SIM_BWR_SOPT8_FTM0CFSEL(base,ftmcarrierfreqsrc); - break; - case 3: - SIM_BWR_SOPT8_FTM3CFSEL(base,ftmcarrierfreqsrc); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmCarrierFreqCmd - * Description : Get FlexTimer x carrier frequency selection software configuration setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetFtmCarrierFreqCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - assert (instance < FTM_INSTANCE_COUNT); - switch(instance) - { - case 0: - retValue = SIM_BRD_SOPT8_FTM0CFSEL(base); - break; - case 3: - retValue = SIM_BRD_SOPT8_FTM3CFSEL(base); - break; - default: - retValue = false; - break; - } - return retValue; -} -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmSyncCmd - * Description : Set FTMxSYNCBIT - * This function sets FlexTimer x hardware trigger 0 software synchronization. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmSyncCmd(SIM_Type* base, uint32_t instance, bool sync) -{ - assert (instance < FTM_INSTANCE_COUNT); - if (sync) - { - SIM_SET_SOPT8(base, (1U< -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = 0U; - *outdiv3 = 0U; - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable settingg - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, uint32_t instance, sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue =(sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - - if (altTrigEn) - { - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartOpenDrainCmd - * Description : Set UARTx Open Drain Enable setting - * This function will enable/disable the UARTx Open Drain. - * - *END**************************************************************************/ -void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 1: - SIM_BWR_SOPT5_UART1ODE(base, enable ? 1 : 0); - break; - case 2: - SIM_BWR_SOPT5_UART2ODE(base, enable ? 1 : 0); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartOpenDrainCmd - * Description : Get UARTx Open Drain Enable setting - * This function will get UARTx Open Drain Enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 1: - retValue = SIM_BRD_SOPT5_UART1ODE(base); - break; - case 2: - retValue = SIM_BRD_SOPT5_UART2ODE(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmExternalClkPinSelMode - * Description : Set Timer/PWM x external clock pin select setting - * This function will select the source of Timer/PWM x external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_TPM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_TPM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_TPM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetTpmExternalClkPinSelMode - * Description : Get Timer/PWM x external clock pin select setting - * This function will get Timer/PWM x external clock pin select setting. - * - *END**************************************************************************/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance) -{ - sim_tpm_clk_sel_t retValue = (sim_tpm_clk_sel_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM0CLKSEL(base); - break; - case 1: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM1CLKSEL(base); - break; - case 2: - retValue = (sim_tpm_clk_sel_t)SIM_BRD_SOPT4_TPM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetTpmChSrcMode - * Description : Timer/PWM x channel y input capture source select setting - * This function will select Timer/PWM x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select) -{ - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - SIM_BWR_SOPT4_TPM1CH0SRC(base, select); - break; - case 2: - SIM_BWR_SOPT4_TPM2CH0SRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetTpmChSrcMode - * Description : Get Timer/PWM x channel y input capture source select setting - * This function will get Timer/PWM x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel) -{ - sim_tpm_ch_src_t retValue = (sim_tpm_ch_src_t)0; - - assert (instance < TPM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM1CH0SRC(base); - break; - case 2: - retValue = (sim_tpm_ch_src_t)SIM_BRD_SOPT4_TPM2CH0SRC(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKW01Z4/fsl_sim_hal_MKW01Z4.h b/KSDK_1.2.0/platform/hal/src/sim/MKW01Z4/fsl_sim_hal_MKW01Z4.h deleted file mode 100644 index 25a3986..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKW01Z4/fsl_sim_hal_MKW01Z4.h +++ /dev/null @@ -1,1397 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_KW01Z4_H__) -#define __FSL_SIM_HAL_KW01Z4_H__ - - -/*! - * @addtogroup sim_hal_kw01z4 - * @{ - */ -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - - /*! @brief COP clock source select */ -typedef enum _clock_cop_src_t -{ - kClockCopSrcLpoClk, /*!< LPO */ - kClockCopSrcAltClk, /*!< Alternative clock, for KW01Z4 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_cop_src_kw01z4_t; -#else -} clock_cop_src_t; -#endif - -/*! @brief TPM clock source select */ -typedef enum _clock_tpm_src -{ - kClockTpmSrcNone, /*!< clock disabled */ - kClockTpmSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTpmSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTpmSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_tpm_src_kw01z4_t; -#else -} clock_tpm_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG out clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk, /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_kw01z4_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief UART0 clock source select */ -typedef enum _clock_lpsci_src -{ - kClockLpsciSrcNone, /*!< clock disabled */ - kClockLpsciSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockLpsciSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockLpsciSrcMcgIrClk /*!< MCGIR clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lpsci_src_kw01z4_t; -#else -} clock_lpsci_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB clock source select */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< USB CLKIN Clock */ - kClockUsbfsSrcPllFllSel /*!< clock as selected by SOPT2[PLLFLLSEL] */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_kw01z4_t; -#else -} clock_usbfs_src_t; -#endif -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_kw01z4_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll, /*!< Fll clock */ - kClockPllFllSelPll /*!< Pll0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_kw01z4_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL) */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC 32k clock */ - kClockEr32kSrcReserved = 1U, /*!< Reserved */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock */ - kClockEr32kSrcLpo = 3U /*!< LPO clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_kw01z4_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutReserved = 0U, /*!< Reserved */ - kClockClkoutReserved1 = 1U, /*!< Reserved */ - kClockClkoutBusClk = 2U, /*!< Bus clock */ - kClockClkoutLpoClk = 3U, /*!< LPO clock */ - kClockClkoutMcgIrClk = 4U, /*!< MCG ir clock */ - kClockClkoutReserved2 = 5U, /*!< Reserved */ - kClockClkoutOsc0erClk = 6U, /*!< OSC0ER clock */ - kClockClkoutReserved3 = 7U /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_kw01z4_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz /*!< 32KHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_kw01z4_t; -#else -} clock_rtcout_src_t; -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_kw01z4_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_kw01z4_t; -#else -} sim_usbvstby_mode_t; -#endif -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_kw01z4_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelComp0 = 1U, /*!< CMP0 output */ - kSimAdcTrgSelReserved = 2U, /*!< Reserved */ - kSimAdcTrgSelReserved1 = 3U, /*!< Reserved */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelReserved2 = 6U, /*!< Reserved */ - kSimAdcTrgSelReserved3 = 7U, /*!< Reserved */ - kSimAdcTrgSelTpm0 = 8U, /*!< TPM0 overflow */ - kSimAdcTrgSelTpm1 = 9U, /*!< TPM1 overflow */ - kSimAdcTrgSelTpm2 = 10U, /*!< TPM2 overflow */ - kSimAdcTrgSelReserved4 = 11U, /*!< Reserved */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U, /*!< Low-power timer trigger */ - kSimAdcTrgSelReserved5 = 15U /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_kw01z4_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_kw01z4_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcTpm1, /*!< UARTx_TX pin modulated with TPM1 channel 0 output */ - kSimUartTxsrcTpm2, /*!< UARTx_TX pin modulated with TPM2 channel 0 output */ - kSimUartTxsrcReserved /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_kw01z4_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM LPSCI receive data source select */ -typedef enum _sim_lpsci_rxsrc -{ - kSimLpsciRxsrcPin, /*!< LPSCIx_RX Pin */ - kSimLpsciRxsrcCmp0, /*!< CMP0 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpsci_rxsrc_kw01z4_t; -#else -} sim_lpsci_rxsrc_t; -#endif - -/*! @brief SIM LPSCI transmit data source select */ -typedef enum _sim_lpsci_txsrc -{ - kSimLpsciTxsrcPin, /*!< LPSCIx_TX Pin */ - kSimLpsciTxsrcTpm1, /*!< LPSCIx_TX pin modulated with TPM1 channel 0 output */ - kSimLpsciTxsrcTpm2, /*!< LPSCIx_TX pin modulated with TPM2 channel 0 output */ - kSimLpsciTxsrcReserved /*!< Reserved */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_lpsci_txsrc_kw01z4_t; -#else -} sim_lpsci_txsrc_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_kw01z4_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1, /*!< CMP0 output */ - kSimTpmChSrc2, /*!< Reserved */ - kSimTpmChSrc3 /*!< USB start of frame pulse */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_kw01z4_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateLpsci0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), -#if FSL_FEATURE_SOC_USB_COUNT - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), -#endif - kSimClockGateCmp0 = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(4U, 22U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(4U, 23U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGateTsi0 = FSL_SIM_SCGC_BIT(5U, 5U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), -#if FSL_FEATURE_SOC_LCD_COUNT - kSimClockGateSlcd0 = FSL_SIM_SCGC_BIT(5U, 19U), -#endif - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateTpm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateTpm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateTpm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(6U, 31U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 8U) -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_kw01z4_t; -#else -} sim_clock_gate_name_t; -#endif - -/*@}*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type * base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type * base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type * base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTpmSrc(SIM_Type * base, - uint32_t instance, - clock_tpm_src_t setting) -{ - SIM_BWR_SOPT2_TPMSRC(base, setting); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_HAL_GetTpmSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_tpm_src_t)SIM_BRD_SOPT2_TPMSRC(base); -} - -/*! - * @brief Set the LPSCI clock source selection. - * - * This function sets the LPSCI clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetLpsciSrc(SIM_Type * base, - uint32_t instance, - clock_lpsci_src_t setting) -{ - SIM_BWR_SOPT2_UART0SRC(base, setting); -} - -/*! - * @brief Get the LPSCI clock source selection. - * - * This function gets the LPSCI clock source selection. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_lpsci_src_t CLOCK_HAL_GetLpsciSrc(SIM_Type * base, - uint32_t instance) -{ - return (clock_lpsci_src_t)SIM_BRD_SOPT2_UART0SRC(base); -} -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type * base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type * base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type * base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type * base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type * base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type * base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type * base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type * base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type * base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type * base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type * base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type * base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type * base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type * base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type * base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type * base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type * base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type * base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type * base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type * base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type * base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -static inline void SIM_HAL_SetUartRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - SIM_BWR_SOPT5_UART1RXSRC(base, select); -} - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -static inline sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); -} - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -static inline void SIM_HAL_SetUartTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - SIM_BWR_SOPT5_UART1TXSRC(base, select); -} - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -static inline sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); -} - -/*! - * @brief Sets the LPSCIx receive data source select setting. - * - * This function selects the source for the LPSCIx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the LPSCIx receive data - */ -static inline void SIM_HAL_SetLpsciRxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpsci_rxsrc_t select) -{ - SIM_BWR_SOPT5_UART0RXSRC(base, select); -} - -/*! - * @brief Gets the LPSCIx receive data source select setting. - * - * This function gets the LPSCIx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select LPSCIx receive data source select setting - */ -static inline sim_lpsci_rxsrc_t SIM_HAL_GetLpsciRxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_lpsci_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); -} - -/*! - * @brief Sets the LPSCIx transmit data source select setting. - * - * This function selects the source for the LPSCIx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the LPSCIx transmit data - */ -static inline void SIM_HAL_SetLpsciTxSrcMode(SIM_Type * base, - uint32_t instance, - sim_lpsci_txsrc_t select) -{ - SIM_BWR_SOPT5_UART0TXSRC(base, select); -} - -/*! - * @brief Gets the LPSCIx transmit data source select setting. - * - * This function gets the LPSCIx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select LPSCIx transmit data source select setting - */ -static inline sim_lpsci_txsrc_t SIM_HAL_GetLpsciTxSrcMode(SIM_Type * base, uint32_t instance) -{ - return (sim_lpsci_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); -} - -#if FSL_FEATURE_SIM_OPT_HAS_ODE -/*! -* @brief Sets the UARTx Open Drain Enable setting. -* -* This function enables/disables the UARTx Open Drain. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @param enable Enable/disable UARTx Open Drain -* - True: Enable UARTx Open Drain -* - False: Disable UARTx Open Drain -*/ -void SIM_HAL_SetUartOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable); - -/*! -* @brief Gets the UARTx Open Drain Enable setting. -* -* This function gets the UARTx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance UART instance. -* @return enabled True if UARTx Open Drain is enabled. -*/ -bool SIM_HAL_GetUartOpenDrainCmd(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the LPSCIx Open Drain Enable setting. -* -* This function enables/disables the LPSCIx Open Drain. -* -* @param base Register base address of SIM. -* @param instance LPSCI instance. -* @param enable Enable/disable LPSCIx Open Drain -* - True: Enable LPSCIx Open Drain -* - False: Disable LPSCIx Open Drain -*/ -static inline void SIM_HAL_SetLpsciOpenDrainCmd(SIM_Type * base, uint32_t instance, bool enable) -{ - SIM_BWR_SOPT5_UART0ODE(base, enable); -} - -/*! -* @brief Gets the LPSCIx Open Drain Enable setting. -* -* This function gets the LPSCIx Open Drain Enable setting. -* -* @param base Register base address of SIM. -* @param instance LPSCI instance. -* @return enabled True if LPSCIx Open Drain is enabled. -*/ -static inline bool SIM_HAL_GetLpsciOpenDrainCmd(SIM_Type * base, uint32_t instance) -{ - return (bool)SIM_BRD_SOPT5_UART0ODE(base); -} -#endif - -#if FSL_FEATURE_SIM_OPT_HAS_TPM -/*! -* @brief Sets the Timer/PWM x external clock pin select setting. -* -* This function selects the source of the Timer/PWM x external clock pin select. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param select Timer/PWM x external clock pin select -*/ -void SIM_HAL_SetTpmExternalClkPinSelMode(SIM_Type * base, - uint32_t instance, - sim_tpm_clk_sel_t select); - -/*! -* @brief Gets the Timer/PWM x external clock pin select setting. -* -* This function gets the Timer/PWM x external clock pin select setting. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @return Timer/PWM x external clock pin select setting -*/ -sim_tpm_clk_sel_t SIM_HAL_GetTpmExternalClkPinSelMode(SIM_Type * base, uint32_t instance); - -/*! -* @brief Sets the Timer/PWM x channel y input capture source select setting. -* -* This function selects the Timer/PWM x channel y input capture source. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @param select Timer/PWM x channel y input capture source -*/ -void SIM_HAL_SetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel, - sim_tpm_ch_src_t select); - -/*! -* @brief Gets the Timer/PWM x channel y input capture source select setting. -* -* This function gets the Timer/PWM x channel y input capture source. -* -* @param base Base address for current SIM instance. -* @param instance device instance. -* @param channel TPM channel y -* @return select Timer/PWM x channel y input capture source -*/ -sim_tpm_ch_src_t SIM_HAL_GetTpmChSrcMode(SIM_Type * base, - uint32_t instance, - uint8_t channel); -#endif - -/*! - * @brief Gets the Kinetis Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Family ID in the System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Family ID - */ -static inline uint32_t SIM_HAL_GetFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Sub-Family ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Sub-Family ID - */ -static inline uint32_t SIM_HAL_GetSubFamilyId(SIM_Type * base) -{ - return SIM_BRD_SDID_SUBFAMID(base); -} - -/*! - * @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Series ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Series ID - */ -static inline uint32_t SIM_HAL_GetSeriesId(SIM_Type * base) -{ - return SIM_BRD_SDID_SERIESID(base); -} - -/*! - * @brief Gets the Kinetis SramSize in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis SramSize in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis SramSize - */ -static inline uint32_t SIM_HAL_GetSramSize(SIM_Type * base) -{ - return SIM_BRD_SDID_SRAMSIZE(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type * base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type * base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the Kinetis Die ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Die ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Die ID - */ -static inline uint32_t SIM_HAL_GetDieId(SIM_Type * base) -{ - return SIM_BRD_SDID_DIEID(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type * base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type * base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type * base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type * base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type * base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type * base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_SIM_HAL_KW01Z4_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKW21D5/fsl_sim_hal_MKW21D5.c b/KSDK_1.2.0/platform/hal/src/sim/MKW21D5/fsl_sim_hal_MKW21D5.c deleted file mode 100755 index 9ed24d9..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKW21D5/fsl_sim_hal_MKW21D5.c +++ /dev/null @@ -1,704 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type* base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type* base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type* base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - - - - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - - - - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type* base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - - - - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type* base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - - - - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type* base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - - - - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type* base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - - - - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type* base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type* base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type* base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type* base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type* base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type* base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - SIM_BWR_SOPT4_FTM0FLT0(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0FLT1(base, select); - break; - default: - break; - } - break; - case 1: - SIM_BWR_SOPT4_FTM1FLT0(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2FLT0(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type* base, - uint32_t instance, - uint8_t fault) -{ - sim_ftm_flt_sel_t retValue = (sim_ftm_flt_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT0(base); - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT1(base); - break; - default: - break; - } - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM1FLT0(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM2FLT0(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKW21D5/fsl_sim_hal_MKW21D5.h b/KSDK_1.2.0/platform/hal/src/sim/MKW21D5/fsl_sim_hal_MKW21D5.h deleted file mode 100644 index 58b667e..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKW21D5/fsl_sim_hal_MKW21D5.h +++ /dev/null @@ -1,1221 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_KW21D5_H__) -#define __FSL_SIM_HAL_KW21D5_H__ - -/*! @addtogroup sim_hal_kw21d5*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief WDOG clock source select */ -typedef enum _clock_wdog_src_t -{ - kClockWdogSrcLpoClk, /* LPO */ - kClockWdogSrcAltClk, /* Alternative clock, for K21DA5 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_wdog_src_kw21d5_t; -#else -} clock_wdog_src_t; -#endif - -/*! @brief Debug trace clock source select */ -typedef enum _clock_trace_src_t -{ - kClockTraceSrcMcgoutClk, /*!< MCG out clock */ - kClockTraceSrcCoreClk /*!< core clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_trace_src_kw21d5_t; -#else -} clock_trace_src_t; -#endif - -/*! @brief PORTx digital input filter clock source select */ -typedef enum _clock_port_filter_src_t -{ - kClockPortFilterSrcBusClk, /*!< Bus clock */ - kClockPortFilterSrcLpoClk /*!< LPO */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_port_filter_src_kw21d5_t; -#else -} clock_port_filter_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG IRC clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_kw21d5_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief SIM timestamp clock source */ -typedef enum _clock_time_src -{ - kClockTimeSrcCoreSysClk, /*!< Core/system clock */ - kClockTimeSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTimeSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTimeSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_time_src_kw21d5_t; -#else -} clock_time_src_t; -#endif - - -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcPllFllSel, /*!< Clock divider USB FS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_kw21d5_t; -#else -} clock_usbfs_src_t; -#endif - - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_kw21d5_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll = 0U, /*!< Fll clock */ - kClockPllFllSelPll = 1U, /*!< Pll0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_kw21d5_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_kw21d5_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCG out clock */ - kClockClkoutSelRtc32kClk = 5U, /*!< RTC 32k clock */ - kClockClkoutSelOsc0erClk = 6U /*!< OSCERCLK0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_kw21d5_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz /*!< 32kHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_kw21d5_t; -#else -} clock_rtcout_src_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_kw21d5_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_kw21d5_t; -#else -} sim_usbvstby_mode_t; -#endif - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_kw21d5_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /*!< High speed comparator 0 output */ - kSimAdcTrgSelHighSpeedComp1 = 2U, /*!< High speed comparator 1 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelPit2 = 6U, /*!< PIT trigger 2 */ - kSimAdcTrgSelPit3 = 7U, /*!< PIT trigger 3 */ - kSimAdcTrgSelFtm0 = 8U, /*!< FTM0 trigger */ - kSimAdcTrgSelFtm1 = 9U, /*!< FTM1 trigger */ - kSimAdcTrgSelFtm2 = 10U, /*!< FTM2 trigger */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_kw21d5_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ - kSimUartRxsrcCmp1, /*!< CMP1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_kw21d5_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcFtm1, /*!< UARTx_TX pin modulated with FTM1 channel 0 output */ - kSimUartTxsrcFtm2 /*!< UARTx_TX pin modulated with FTM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_kw21d5_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM FlexTimer x trigger y select */ -typedef enum _sim_ftm_trg_src -{ - kSimFtmTrgSrc0, /*!< FlexTimer x trigger y select 0 */ - kSimFtmTrgSrc1 /*!< FlexTimer x trigger y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_trg_src_kw21d5_t; -#else -} sim_ftm_trg_src_t; -#endif - -/*! @brief SIM FlexTimer external clock select */ -typedef enum _sim_ftm_clk_sel -{ - kSimFtmClkSel0, /*!< FTM CLKIN0 pin. */ - kSimFtmClkSel1 /*!< FTM CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_clk_sel_kw21d5_t; -#else -} sim_ftm_clk_sel_t; -#endif - -/*! @brief SIM FlexTimer x channel y input capture source select */ -typedef enum _sim_ftm_ch_src -{ - kSimFtmChSrc0, /*!< FlexTimer x channel y input capture source 0. */ - kSimFtmChSrc1, /*!< FlexTimer x channel y input capture source 1. */ - kSimFtmChSrc2, /*!< FlexTimer x channel y input capture source 2. */ - kSimFtmChSrc3 /*!< FlexTimer x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_ch_src_kw21d5_t; -#else -} sim_ftm_ch_src_t; -#endif - -/*! @brief SIM FlexTimer x Fault y select */ -typedef enum _sim_ftm_flt_sel -{ - kSimFtmFltSel0, /*!< FlexTimer x fault y select 0 */ - kSimFtmFltSel1 /*!< FlexTimer x fault y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_flt_sel_kw21d5_t; -#else -} sim_ftm_flt_sel_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_kw21d5_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1 /*!< CMP0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_kw21d5_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM CMT/UART pad drive strength */ -typedef enum _sim_cmtuartpad_strengh -{ - kSimCmtuartSinglePad, /*!< Single-pad drive strength for CMT IRO or UART0_TXD */ - kSimCmtuartDualPad /*!< Dual-pad drive strength for CMT IRO or UART0_TXD */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_cmtuartpad_strengh_kw21d5_t; -#else -} sim_cmtuartpad_strengh_t; -#endif - -/*! @brief SIM PTD7 pad drive strength */ -typedef enum _sim_ptd7pad_strengh -{ - kSimPtd7padSinglePad, /*!< Single-pad drive strength for PTD7 */ - kSimPtd7padDualPad /*!< Dual-pad drive strength for PTD7 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ptd7pad_strengh_kw21d5_t; -#else -} sim_ptd7pad_strengh_t; -#endif - - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateEwm0 = FSL_SIM_SCGC_BIT(4U, 1U), - kSimClockGateCmt0 = FSL_SIM_SCGC_BIT(4U, 2U), - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUart3 = FSL_SIM_SCGC_BIT(4U, 13U), - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), - kSimClockGateCmp = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateRnga0 = FSL_SIM_SCGC_BIT(6U, 9U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(6U, 12U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(6U, 13U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), - kSimClockGateUsbdcd0 = FSL_SIM_SCGC_BIT(6U, 21U), - kSimClockGatePdb0 = FSL_SIM_SCGC_BIT(6U, 22U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateFtm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateFtm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateFtm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(6U, 31U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 1U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_kw21d5_t; -#else -} sim_clock_gate_name_t; -#endif - - -/*! @} */ -/******************************************************************************* - * API - ******************************************************************************/ - - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type* base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type* base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type* base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type* base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type* base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type* base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type* base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set debug trace clock selection. - * - * This function sets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTraceClkSrc(SIM_Type* base, clock_trace_src_t setting) -{ - SIM_BWR_SOPT2_TRACECLKSEL(base, setting); -} - -/*! - * @brief Get debug trace clock selection. - * - * This function gets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_trace_src_t CLOCK_HAL_GetTraceClkSrc(SIM_Type* base) -{ - return (clock_trace_src_t)SIM_BRD_SOPT2_TRACECLKSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type* base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type* base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type* base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type* base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type* base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type* base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV2. - * - * This function sets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv2(SIM_Type* base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV2(base, setting); -} - -/*! - * @brief Get OUTDIV2. - * - * This function gets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv2(SIM_Type* base) -{ - return SIM_BRD_CLKDIV1_OUTDIV2(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type* base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type* base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type* base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type* base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type* base, - uint8_t usbdiv, - uint8_t usbfrac); - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type* base, - uint8_t *usbdiv, - uint8_t *usbfrac); - -/*! - * @brief Gets RAM size. - * - * This function gets the RAM size. The field specifies the amount of system RAM - * available on the device. - * - * @param base Base address for current SIM instance. - * @return size RAM size on the device - */ -static inline uint32_t SIM_HAL_GetRamSize(SIM_Type* base) -{ - return SIM_BRD_SOPT1_RAMSIZE(base); -} - -/*! - * @brief Sets the PTD7 pad drive strength setting. - * - * This function controls the output drive strength of the PTD7 pin by selecting - * either one or two pads to drive it. - * - * @param base Base address for current SIM instance. - * @param setting PTD7 pad drive strength setting - * - 0: Single-pad drive strength for PTD7. - * - 1: Double pad drive strength for PTD7. - */ -static inline void SIM_HAL_SetPtd7PadDriveStrengthMode(SIM_Type* base, - sim_ptd7pad_strengh_t setting) -{ - SIM_BWR_SOPT2_PTD7PAD(base, setting); -} - -/*! - * @brief Gets the PTD7 pad drive strength setting. - * - * This function gets the PTD7 pad drive strength setting. - * - * @param base Base address for current SIM instance. - * @return setting PTD7 pad drive strength setting - */ -static inline sim_ptd7pad_strengh_t SIM_HAL_GetPtd7PadDriveStrengthMode(SIM_Type* base) -{ - return (sim_ptd7pad_strengh_t)SIM_BRD_SOPT2_PTD7PAD(base); -} - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type* base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type* base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type* base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type* base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type* base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type* base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -void SIM_HAL_SetUartRxSrcMode(SIM_Type* base, - uint32_t instance, - sim_uart_rxsrc_t select); - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type* base, uint32_t instance); - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -void SIM_HAL_SetUartTxSrcMode(SIM_Type* base, - uint32_t instance, - sim_uart_txsrc_t select); - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type* base, uint32_t instance); - -/*! - * @brief Sets the FlexTimer x hardware trigger y source select setting. - * - * This function selects the source of FTMx hardware trigger y. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @param select FlexTimer x hardware trigger y - * - 0: Pre-trigger A selected for ADCx. - * - 1: Pre-trigger B selected for ADCx. - */ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select); - -/*! - * @brief Gets the FlexTimer x hardware trigger y source select setting. - * - * This function gets the FlexTimer x hardware trigger y source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @return select FlexTimer x hardware trigger y source select setting - */ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t trigger); - -/*! - * @brief Sets the FlexTimer x external clock pin select setting. - * - * This function selects the source of FTMx external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select FTMx external clock pin select - * - 0: FTMx external clock driven by FTM CLKIN0 pin. - * - 1: FTMx external clock driven by FTM CLKIN1 pin. - */ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance, - sim_ftm_clk_sel_t select); - -/*! - * @brief Gets the FlexTimer x external clock pin select setting. - * - * This function gets the FlexTimer x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select FlexTimer x external clock pin select setting - */ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance); - -/*! - * @brief Sets the FlexTimer x channel y input capture source select setting. - * - * This function selects the FlexTimer x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y input capture source - */ -void SIM_HAL_SetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y input capture source select setting. - * - * This function gets the FlexTimer x channel y input capture - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y input capture source select setting - */ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Sets the FlexTimer x fault y select setting. - * - * This function sets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @param select FlexTimer x fault y select setting - * - 0: FlexTimer x fault y select 0. - * - 1: FlexTimer x fault y select 1. - */ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type* base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select); - -/*! - * @brief Gets the FlexTimer x fault y select setting. - * - * This function gets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @return select FlexTimer x fault y select setting - */ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type* base, - uint32_t instance, - uint8_t fault); - -/*! - * @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Fam ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Fam ID - */ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type* base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type* base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type* base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the FlexNVM size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size FlexNVM Size - */ -static inline uint32_t SIM_HAL_GetFlexnvmSize(SIM_Type* base) -{ - return SIM_BRD_FCFG1_NVMSIZE(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type* base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Gets the EEProm size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the EEProm size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size EEProm Size - */ -static inline uint32_t SIM_HAL_GetEepromSize(SIM_Type* base) -{ - return SIM_BRD_FCFG1_EESIZE(base); -} - -/*! - * @brief Gets the FlexNVM partition in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM partition in the Flash Configuration Register1 - * - * @param base Base address for current SIM instance. - * @return setting FlexNVM partition setting - */ -static inline uint32_t SIM_HAL_GetFlexnvmPartition(SIM_Type* base) -{ - return SIM_BRD_FCFG1_DEPART(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type* base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type* base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type* base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type* base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type* base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type* base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -/*! - * @brief Gets the program flash in the Flash Configuration Register 2. - * - * This function gets the program flash maximum block 0 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return status program flash status - */ -static inline uint32_t SIM_HAL_GetProgramFlashCmd(SIM_Type* base) -{ - return SIM_BRD_FCFG2_PFLSH(base); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ -/*! @}*/ - - -#endif /* __FSL_SIM_HAL_KW21D5_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKW22D5/fsl_sim_hal_MKW22D5.c b/KSDK_1.2.0/platform/hal/src/sim/MKW22D5/fsl_sim_hal_MKW22D5.c deleted file mode 100755 index 446b214..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKW22D5/fsl_sim_hal_MKW22D5.c +++ /dev/null @@ -1,734 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type* base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfDiv - * Description : Gets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type* base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type* base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type* base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type* base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - - - - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - - - - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type* base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - - - - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type* base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - - - - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type* base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - - - - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type* base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - - - - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type* base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type* base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type* base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type* base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type* base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type* base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - SIM_BWR_SOPT4_FTM0FLT0(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0FLT1(base, select); - break; - default: - break; - } - break; - case 1: - SIM_BWR_SOPT4_FTM1FLT0(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2FLT0(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type* base, - uint32_t instance, - uint8_t fault) -{ - sim_ftm_flt_sel_t retValue = (sim_ftm_flt_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT0(base); - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT1(base); - break; - default: - break; - } - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM1FLT0(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM2FLT0(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKW22D5/fsl_sim_hal_MKW22D5.h b/KSDK_1.2.0/platform/hal/src/sim/MKW22D5/fsl_sim_hal_MKW22D5.h deleted file mode 100644 index a456993..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKW22D5/fsl_sim_hal_MKW22D5.h +++ /dev/null @@ -1,1436 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_KW22D5_H__) -#define __FSL_SIM_HAL_KW22D5_H__ - -/*! @addtogroup sim_hal_kw22d5*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief WDOG clock source select */ -typedef enum _clock_wdog_src_t -{ - kClockWdogSrcLpoClk, /* LPO */ - kClockWdogSrcAltClk, /* Alternative clock, for K21DA5 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_wdog_src_kw22d5_t; -#else -} clock_wdog_src_t; -#endif - -/*! @brief Debug trace clock source select */ -typedef enum _clock_trace_src_t -{ - kClockTraceSrcMcgoutClk, /*!< MCG out clock */ - kClockTraceSrcCoreClk /*!< core clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_trace_src_kw22d5_t; -#else -} clock_trace_src_t; -#endif - -/*! @brief PORTx digital input filter clock source select */ -typedef enum _clock_port_filter_src_t -{ - kClockPortFilterSrcBusClk, /*!< Bus clock */ - kClockPortFilterSrcLpoClk /*!< LPO */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_port_filter_src_kw22d5_t; -#else -} clock_port_filter_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG IRC clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_kw22d5_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief SIM timestamp clock source */ -typedef enum _clock_time_src -{ - kClockTimeSrcCoreSysClk, /*!< Core/system clock */ - kClockTimeSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTimeSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTimeSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_time_src_kw22d5_t; -#else -} clock_time_src_t; -#endif - - -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcPllFllSel, /*!< Clock divider USB FS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_kw22d5_t; -#else -} clock_usbfs_src_t; -#endif - - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_kw22d5_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll = 0U, /*!< Fll clock */ - kClockPllFllSelPll = 1U, /*!< Pll0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_kw22d5_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_kw22d5_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCG out clock */ - kClockClkoutSelRtc32kClk = 5U, /*!< RTC 32k clock */ - kClockClkoutSelOsc0erClk = 6U /*!< OSCERCLK0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_kw22d5_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz /*!< 32kHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_kw22d5_t; -#else -} clock_rtcout_src_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_kw22d5_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_kw22d5_t; -#else -} sim_usbvstby_mode_t; -#endif - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_kw22d5_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /*!< High speed comparator 0 output */ - kSimAdcTrgSelHighSpeedComp1 = 2U, /*!< High speed comparator 1 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelPit2 = 6U, /*!< PIT trigger 2 */ - kSimAdcTrgSelPit3 = 7U, /*!< PIT trigger 3 */ - kSimAdcTrgSelFtm0 = 8U, /*!< FTM0 trigger */ - kSimAdcTrgSelFtm1 = 9U, /*!< FTM1 trigger */ - kSimAdcTrgSelFtm2 = 10U, /*!< FTM2 trigger */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_kw22d5_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ - kSimUartRxsrcCmp1, /*!< CMP1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_kw22d5_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcFtm1, /*!< UARTx_TX pin modulated with FTM1 channel 0 output */ - kSimUartTxsrcFtm2 /*!< UARTx_TX pin modulated with FTM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_kw22d5_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM FlexTimer x trigger y select */ -typedef enum _sim_ftm_trg_src -{ - kSimFtmTrgSrc0, /*!< FlexTimer x trigger y select 0 */ - kSimFtmTrgSrc1 /*!< FlexTimer x trigger y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_trg_src_kw22d5_t; -#else -} sim_ftm_trg_src_t; -#endif - -/*! @brief SIM FlexTimer external clock select */ -typedef enum _sim_ftm_clk_sel -{ - kSimFtmClkSel0, /*!< FTM CLKIN0 pin. */ - kSimFtmClkSel1 /*!< FTM CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_clk_sel_kw22d5_t; -#else -} sim_ftm_clk_sel_t; -#endif - -/*! @brief SIM FlexTimer x channel y input capture source select */ -typedef enum _sim_ftm_ch_src -{ - kSimFtmChSrc0, /*!< FlexTimer x channel y input capture source 0. */ - kSimFtmChSrc1, /*!< FlexTimer x channel y input capture source 1. */ - kSimFtmChSrc2, /*!< FlexTimer x channel y input capture source 2. */ - kSimFtmChSrc3 /*!< FlexTimer x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_ch_src_kw22d5_t; -#else -} sim_ftm_ch_src_t; -#endif - -/*! @brief SIM FlexTimer x Fault y select */ -typedef enum _sim_ftm_flt_sel -{ - kSimFtmFltSel0, /*!< FlexTimer x fault y select 0 */ - kSimFtmFltSel1 /*!< FlexTimer x fault y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_flt_sel_kw22d5_t; -#else -} sim_ftm_flt_sel_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_kw22d5_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1 /*!< CMP0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_kw22d5_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM CMT/UART pad drive strength */ -typedef enum _sim_cmtuartpad_strengh -{ - kSimCmtuartSinglePad, /*!< Single-pad drive strength for CMT IRO or UART0_TXD */ - kSimCmtuartDualPad /*!< Dual-pad drive strength for CMT IRO or UART0_TXD */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_cmtuartpad_strengh_kw22d5_t; -#else -} sim_cmtuartpad_strengh_t; -#endif - -/*! @brief SIM PTD7 pad drive strength */ -typedef enum _sim_ptd7pad_strengh -{ - kSimPtd7padSinglePad, /*!< Single-pad drive strength for PTD7 */ - kSimPtd7padDualPad /*!< Dual-pad drive strength for PTD7 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ptd7pad_strengh_kw22d5_t; -#else -} sim_ptd7pad_strengh_t; -#endif - - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateEwm0 = FSL_SIM_SCGC_BIT(4U, 1U), - kSimClockGateCmt0 = FSL_SIM_SCGC_BIT(4U, 2U), - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUart3 = FSL_SIM_SCGC_BIT(4U, 13U), - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), - kSimClockGateCmp = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateRnga0 = FSL_SIM_SCGC_BIT(6U, 9U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(6U, 12U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(6U, 13U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), - kSimClockGateUsbdcd0 = FSL_SIM_SCGC_BIT(6U, 21U), - kSimClockGatePdb0 = FSL_SIM_SCGC_BIT(6U, 22U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateFtm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateFtm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateFtm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(6U, 31U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 1U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_kw22d5_t; -#else -} sim_clock_gate_name_t; -#endif - - -/*! @} */ -/******************************************************************************* - * API - ******************************************************************************/ - - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type* base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type* base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type* base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type* base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type* base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type* base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type* base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type* base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type* base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set debug trace clock selection. - * - * This function sets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTraceClkSrc(SIM_Type* base, clock_trace_src_t setting) -{ - SIM_BWR_SOPT2_TRACECLKSEL(base, setting); -} - -/*! - * @brief Get debug trace clock selection. - * - * This function gets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_trace_src_t CLOCK_HAL_GetTraceClkSrc(SIM_Type* base) -{ - return (clock_trace_src_t)SIM_BRD_SOPT2_TRACECLKSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type* base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type* base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type* base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type* base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type* base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type* base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV2. - * - * This function sets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv2(SIM_Type* base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV2(base, setting); -} - -/*! - * @brief Get OUTDIV2. - * - * This function gets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv2(SIM_Type* base) -{ - return SIM_BRD_CLKDIV1_OUTDIV2(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type* base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type* base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type* base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type* base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type* base, - uint8_t usbdiv, - uint8_t usbfrac); - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type* base, - uint8_t *usbdiv, - uint8_t *usbfrac); - -/*! - * @brief Gets RAM size. - * - * This function gets the RAM size. The field specifies the amount of system RAM - * available on the device. - * - * @param base Base address for current SIM instance. - * @return size RAM size on the device - */ -static inline uint32_t SIM_HAL_GetRamSize(SIM_Type* base) -{ - return SIM_BRD_SOPT1_RAMSIZE(base); -} - -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type* base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type* base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type* base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type* base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type* base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type* base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type* base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type* base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type* base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type* base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type* base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type* base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} - -/*! - * @brief Sets the PTD7 pad drive strength setting. - * - * This function controls the output drive strength of the PTD7 pin by selecting - * either one or two pads to drive it. - * - * @param base Base address for current SIM instance. - * @param setting PTD7 pad drive strength setting - * - 0: Single-pad drive strength for PTD7. - * - 1: Double pad drive strength for PTD7. - */ -static inline void SIM_HAL_SetPtd7PadDriveStrengthMode(SIM_Type* base, - sim_ptd7pad_strengh_t setting) -{ - SIM_BWR_SOPT2_PTD7PAD(base, setting); -} - -/*! - * @brief Gets the PTD7 pad drive strength setting. - * - * This function gets the PTD7 pad drive strength setting. - * - * @param base Base address for current SIM instance. - * @return setting PTD7 pad drive strength setting - */ -static inline sim_ptd7pad_strengh_t SIM_HAL_GetPtd7PadDriveStrengthMode(SIM_Type* base) -{ - return (sim_ptd7pad_strengh_t)SIM_BRD_SOPT2_PTD7PAD(base); -} - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type* base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type* base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type* base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type* base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type* base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type* base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -void SIM_HAL_SetUartRxSrcMode(SIM_Type* base, - uint32_t instance, - sim_uart_rxsrc_t select); - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type* base, uint32_t instance); - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -void SIM_HAL_SetUartTxSrcMode(SIM_Type* base, - uint32_t instance, - sim_uart_txsrc_t select); - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type* base, uint32_t instance); - -/*! - * @brief Sets the FlexTimer x hardware trigger y source select setting. - * - * This function selects the source of FTMx hardware trigger y. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @param select FlexTimer x hardware trigger y - * - 0: Pre-trigger A selected for ADCx. - * - 1: Pre-trigger B selected for ADCx. - */ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select); - -/*! - * @brief Gets the FlexTimer x hardware trigger y source select setting. - * - * This function gets the FlexTimer x hardware trigger y source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @return select FlexTimer x hardware trigger y source select setting - */ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t trigger); - -/*! - * @brief Sets the FlexTimer x external clock pin select setting. - * - * This function selects the source of FTMx external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select FTMx external clock pin select - * - 0: FTMx external clock driven by FTM CLKIN0 pin. - * - 1: FTMx external clock driven by FTM CLKIN1 pin. - */ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance, - sim_ftm_clk_sel_t select); - -/*! - * @brief Gets the FlexTimer x external clock pin select setting. - * - * This function gets the FlexTimer x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select FlexTimer x external clock pin select setting - */ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance); - -/*! - * @brief Sets the FlexTimer x channel y input capture source select setting. - * - * This function selects the FlexTimer x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y input capture source - */ -void SIM_HAL_SetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y input capture source select setting. - * - * This function gets the FlexTimer x channel y input capture - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y input capture source select setting - */ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Sets the FlexTimer x fault y select setting. - * - * This function sets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @param select FlexTimer x fault y select setting - * - 0: FlexTimer x fault y select 0. - * - 1: FlexTimer x fault y select 1. - */ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type* base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select); - -/*! - * @brief Gets the FlexTimer x fault y select setting. - * - * This function gets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @return select FlexTimer x fault y select setting - */ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type* base, - uint32_t instance, - uint8_t fault); - -/*! - * @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Fam ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Fam ID - */ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type* base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type* base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type* base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the FlexNVM size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size FlexNVM Size - */ -static inline uint32_t SIM_HAL_GetFlexnvmSize(SIM_Type* base) -{ - return SIM_BRD_FCFG1_NVMSIZE(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type* base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Gets the EEProm size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the EEProm size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size EEProm Size - */ -static inline uint32_t SIM_HAL_GetEepromSize(SIM_Type* base) -{ - return SIM_BRD_FCFG1_EESIZE(base); -} - -/*! - * @brief Gets the FlexNVM partition in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM partition in the Flash Configuration Register1 - * - * @param base Base address for current SIM instance. - * @return setting FlexNVM partition setting - */ -static inline uint32_t SIM_HAL_GetFlexnvmPartition(SIM_Type* base) -{ - return SIM_BRD_FCFG1_DEPART(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type* base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type* base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type* base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type* base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type* base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type* base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -/*! - * @brief Gets the program flash in the Flash Configuration Register 2. - * - * This function gets the program flash maximum block 0 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return status program flash status - */ -static inline uint32_t SIM_HAL_GetProgramFlashCmd(SIM_Type* base) -{ - return SIM_BRD_FCFG2_PFLSH(base); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ -/*! @}*/ - - -#endif /* __FSL_SIM_HAL_KW22D5_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKW24D5/fsl_sim_hal_MKW24D5.c b/KSDK_1.2.0/platform/hal/src/sim/MKW24D5/fsl_sim_hal_MKW24D5.c deleted file mode 100755 index 446b214..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKW24D5/fsl_sim_hal_MKW24D5.c +++ /dev/null @@ -1,734 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/******************************************************************************* - * APIs - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetUsbfsDiv - * Description : Sets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type* base, - uint8_t usbdiv, - uint8_t usbfrac) -{ - SIM_BWR_CLKDIV2_USBDIV(base, usbdiv); - SIM_BWR_CLKDIV2_USBFRAC(base, usbfrac); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetUsbfDiv - * Description : Gets USB divider setting. - * Divider output clock = Divider input clock * [ (USBFRAC+1) / (USBDIV+1) ] - * - *END**************************************************************************/ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type* base, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - *usbdiv = SIM_BRD_CLKDIV2_USBDIV(base); - *usbfrac = SIM_BRD_CLKDIV2_USBFRAC(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_SetOutDiv - * Description : Set all clock out dividers setting at the same time - * This function will set the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_SetOutDiv(SIM_Type* base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4) -{ - uint32_t clkdiv1 = 0; - - clkdiv1 |= SIM_CLKDIV1_OUTDIV1(outdiv1); - clkdiv1 |= SIM_CLKDIV1_OUTDIV2(outdiv2); - clkdiv1 |= SIM_CLKDIV1_OUTDIV4(outdiv4); - - SIM_WR_CLKDIV1(base, clkdiv1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_HAL_GetOutDiv - * Description : Get all clock out dividers setting at the same time - * This function will get the setting for all clock out dividers. - * - *END**************************************************************************/ -void CLOCK_HAL_GetOutDiv(SIM_Type* base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4) -{ - *outdiv1 = SIM_BRD_CLKDIV1_OUTDIV1(base); - *outdiv2 = SIM_BRD_CLKDIV1_OUTDIV2(base); - *outdiv4 = SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcAlternativeTriggerCmd - * Description : Set ADCx alternate trigger enable setting - * This function will enable/disable alternative conversion triggers for ADCx. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type* base, - uint32_t instance, - bool enable) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, enable ? 1 : 0); - break; - - - - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcAlternativeTriggerCmd - * Description : Get ADCx alternate trigger enable setting - * This function will get ADCx alternate trigger enable setting. - * - *END**************************************************************************/ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type* base, uint32_t instance) -{ - bool retValue = false; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = SIM_BRD_SOPT7_ADC0ALTTRGEN(base); - break; - - - - default: - retValue = false; - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcPreTriggerMode - * Description : Set ADCx pre-trigger select setting - * This function will select the ADCx pre-trigger source when alternative - * triggers are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type* base, - uint32_t instance, - sim_adc_pretrg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, select); - break; - - - - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcPreTriggerMode - * Description : Get ADCx pre-trigger select setting - * This function will get ADCx pre-trigger select setting. - * - *END**************************************************************************/ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type* base, - uint32_t instance) -{ - sim_adc_pretrg_sel_t retValue = (sim_adc_pretrg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_pretrg_sel_t)SIM_BRD_SOPT7_ADC0PRETRGSEL(base); - break; - - - - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerMode - * Description : Set ADCx trigger select setting - * This function will select the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type* base, - uint32_t instance, - sim_adc_trg_sel_t select) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, select); - break; - - - - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetAdcTriggerMode - * Description : Get ADCx trigger select setting - * This function will get ADCx trigger select setting. - * - *END**************************************************************************/ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type* base, uint32_t instance) -{ - sim_adc_trg_sel_t retValue = (sim_adc_trg_sel_t)0; - - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_adc_trg_sel_t)SIM_BRD_SOPT7_ADC0TRGSEL(base); - break; - - - - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetAdcTriggerModeOneStep - * Description : Set ADCx trigger setting. - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - *END**************************************************************************/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type* base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel) -{ - assert(instance < ADC_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0ALTTRGEN(base, altTrigEn ? 1 : 0); - SIM_BWR_SOPT7_ADC0PRETRGSEL(base, preTrigSel); - break; - - default: - break; - } - - if (altTrigEn) - { - switch (instance) - { - case 0: - SIM_BWR_SOPT7_ADC0TRGSEL(base, trigSel); - break; - default: - break; - } - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartRxSrcMode - * Description : Set UARTx receive data source select setting - * This function will select the source for the UART1 receive data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartRxSrcMode(SIM_Type* base, - uint32_t instance, - sim_uart_rxsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0RXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1RXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartRxSrcMode - * Description : Get UARTx receive data source select setting - * This function will get UARTx receive data source select setting. - * - *END**************************************************************************/ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type* base, uint32_t instance) -{ - sim_uart_rxsrc_t retValue = (sim_uart_rxsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART0RXSRC(base); - break; - case 1: - retValue = (sim_uart_rxsrc_t)SIM_BRD_SOPT5_UART1RXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetUartTxSrcMode - * Description : Set UARTx transmit data source select setting - * This function will select the source for the UARTx transmit data. - * - *END**************************************************************************/ -void SIM_HAL_SetUartTxSrcMode(SIM_Type* base, - uint32_t instance, - sim_uart_txsrc_t select) -{ - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT5_UART0TXSRC(base, select); - break; - case 1: - SIM_BWR_SOPT5_UART1TXSRC(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartTxSrcMode - * Description : Get UARTx transmit data source select setting - * This function will get UARTx transmit data source select setting. - * - *END**************************************************************************/ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type* base, uint32_t instance) -{ - sim_uart_txsrc_t retValue =(sim_uart_txsrc_t)0; - - assert(instance < FSL_FEATURE_SIM_OPT_UART_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART0TXSRC(base); - break; - case 1: - retValue = (sim_uart_txsrc_t)SIM_BRD_SOPT5_UART1TXSRC(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmTriggerSrcMode - * Description : Set FlexTimer x hardware trigger y source select setting - * This function will select the source of FTMx hardware trigger y. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - SIM_BWR_SOPT4_FTM0TRG0SRC(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0TRG1SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmTriggerSrcMode - * Description : Get FlexTimer x hardware trigger y source select setting - * This function will get FlexTimer x hardware trigger y source select setting. - * - *END**************************************************************************/ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t trigger) -{ - sim_ftm_trg_src_t retValue = (sim_ftm_trg_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - assert (trigger < FSL_FEATURE_SIM_OPT_FTM_TRIGGER_COUNT); - - switch (instance) - { - case 0: - switch (trigger) - { - case 0: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG0SRC(base); - break; - case 1: - retValue = (sim_ftm_trg_src_t)SIM_BRD_SOPT4_FTM0TRG1SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmExternalClkPinMode - * Description : Set FlexTimer x external clock pin select setting - * This function will select the source of FTMx external clock pin select - * - *END**************************************************************************/ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance, - sim_ftm_clk_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - SIM_BWR_SOPT4_FTM0CLKSEL(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM1CLKSEL(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2CLKSEL(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmExternalClkPinMode - * Description : Get FlexTimer x external clock pin select setting - * This function will get FlexTimer x external clock pin select setting. - * - *END**************************************************************************/ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance) -{ - sim_ftm_clk_sel_t retValue = (sim_ftm_clk_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM0CLKSEL(base); - break; - case 1: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM1CLKSEL(base); - break; - case 2: - retValue = (sim_ftm_clk_sel_t)SIM_BRD_SOPT4_FTM2CLKSEL(base); - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmChSrcMode - * Description : FlexTimer x channel y input capture source select setting - * This function will select FlexTimer x channel y input capture source - * - *END**************************************************************************/ -void SIM_HAL_SetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM1CH0SRC(base, select); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - SIM_BWR_SOPT4_FTM2CH0SRC(base, select); - break; - default: - break; - } - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmChSrcMode - * Description : Get FlexTimer x channel y input capture source select setting - * This function will get FlexTimer x channel y input capture source select - * setting. - * - *END**************************************************************************/ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel) -{ - sim_ftm_ch_src_t retValue = (sim_ftm_ch_src_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 1: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM1CH0SRC(base); - break; - default: - break; - } - break; - case 2: - switch (channel) - { - case 0: - retValue = (sim_ftm_ch_src_t)SIM_BRD_SOPT4_FTM2CH0SRC(base); - break; - default: - break; - } - break; - default: - break; - } - - return retValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_SetFtmFaultSelMode - * Description : Set FlexTimer x fault y select setting - * This function will set the FlexTimer x fault y select setting. - * - *END**************************************************************************/ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type* base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select) -{ - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - SIM_BWR_SOPT4_FTM0FLT0(base, select); - break; - case 1: - SIM_BWR_SOPT4_FTM0FLT1(base, select); - break; - default: - break; - } - break; - case 1: - SIM_BWR_SOPT4_FTM1FLT0(base, select); - break; - case 2: - SIM_BWR_SOPT4_FTM2FLT0(base, select); - break; - default: - break; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetFtmFaultSelMode - * Description : Get FlexTimer x fault y select setting - * This function will get FlexTimer x fault y select setting. - * - *END**************************************************************************/ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type* base, - uint32_t instance, - uint8_t fault) -{ - sim_ftm_flt_sel_t retValue = (sim_ftm_flt_sel_t)0; - - assert (instance < FTM_INSTANCE_COUNT); - - switch (instance) - { - case 0: - switch (fault) - { - case 0: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT0(base); - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM0FLT1(base); - break; - default: - break; - } - break; - case 1: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM1FLT0(base); - break; - case 2: - retValue = (sim_ftm_flt_sel_t)SIM_BRD_SOPT4_FTM2FLT0(base); - break; - default: - break; - } - - return retValue; -} - -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/hal/src/sim/MKW24D5/fsl_sim_hal_MKW24D5.h b/KSDK_1.2.0/platform/hal/src/sim/MKW24D5/fsl_sim_hal_MKW24D5.h deleted file mode 100644 index 355ff5c..0000000 --- a/KSDK_1.2.0/platform/hal/src/sim/MKW24D5/fsl_sim_hal_MKW24D5.h +++ /dev/null @@ -1,1437 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_SIM_HAL_KW24D5_H__) -#define __FSL_SIM_HAL_KW24D5_H__ - -/*! @addtogroup sim_hal_kw24d5*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief WDOG clock source select */ -typedef enum _clock_wdog_src_t -{ - kClockWdogSrcLpoClk, /* LPO */ - kClockWdogSrcAltClk, /* Alternative clock, for K21DA5 it is Bus clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_wdog_src_kw24d5_t; -#else -} clock_wdog_src_t; -#endif - -/*! @brief Debug trace clock source select */ -typedef enum _clock_trace_src_t -{ - kClockTraceSrcMcgoutClk, /*!< MCG out clock */ - kClockTraceSrcCoreClk /*!< core clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_trace_src_kw24d5_t; -#else -} clock_trace_src_t; -#endif - -/*! @brief PORTx digital input filter clock source select */ -typedef enum _clock_port_filter_src_t -{ - kClockPortFilterSrcBusClk, /*!< Bus clock */ - kClockPortFilterSrcLpoClk /*!< LPO */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_port_filter_src_kw24d5_t; -#else -} clock_port_filter_src_t; -#endif - -/*! @brief LPTMR clock source select */ -typedef enum _clock_lptmr_src_t -{ - kClockLptmrSrcMcgIrClk, /*!< MCG IRC clock */ - kClockLptmrSrcLpoClk, /*!< LPO clock */ - kClockLptmrSrcEr32kClk, /*!< ERCLK32K clock */ - kClockLptmrSrcOsc0erClk /*!< OSCERCLK clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_lptmr_src_kw24d5_t; -#else -} clock_lptmr_src_t; -#endif - -/*! @brief SIM timestamp clock source */ -typedef enum _clock_time_src -{ - kClockTimeSrcCoreSysClk, /*!< Core/system clock */ - kClockTimeSrcPllFllSel, /*!< clock as selected by SOPT2[PLLFLLSEL]. */ - kClockTimeSrcOsc0erClk, /*!< OSCERCLK clock */ - kClockTimeSrcExt /*!< ENET 1588 clock in (ENET_1588_CLKIN) */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_time_src_kw24d5_t; -#else -} clock_time_src_t; -#endif - - -/*! @brief SIM USB FS clock source */ -typedef enum _clock_usbfs_src -{ - kClockUsbfsSrcExt, /*!< External bypass clock (USB_CLKIN) */ - kClockUsbfsSrcPllFllSel, /*!< Clock divider USB FS clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_usbfs_src_kw24d5_t; -#else -} clock_usbfs_src_t; -#endif - - -/*! @brief SAI clock source */ -typedef enum _clock_sai_src -{ - kClockSaiSrcSysClk = 0U, /*!< SYSCLK */ - kClockSaiSrcOsc0erClk = 1U, /*!< OSC0ERCLK */ - kClockSaiSrcPllClk = 3U /*!< MCGPLLCLK */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_sai_src_kw24d5_t; -#else -} clock_sai_src_t; -#endif - -/*! @brief SIM PLLFLLSEL clock source select */ -typedef enum _clock_pllfll_sel -{ - kClockPllFllSelFll = 0U, /*!< Fll clock */ - kClockPllFllSelPll = 1U, /*!< Pll0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_pllfll_sel_kw24d5_t; -#else -} clock_pllfll_sel_t; -#endif - -/*! @brief SIM external reference clock source select (OSC32KSEL). */ -typedef enum _clock_er32k_src -{ - kClockEr32kSrcOsc0 = 0U, /*!< OSC0 clock (OSC032KCLK). */ - kClockEr32kSrcRtc = 2U, /*!< RTC 32k clock . */ - kClockEr32kSrcLpo = 3U /*!< LPO clock. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_er32k_src_kw24d5_t; -#else -} clock_er32k_src_t; -#endif - -/*! @brief SIM CLKOUT_SEL clock source select */ -typedef enum _clock_clkout_src -{ - kClockClkoutSelFlashClk = 2U, /*!< Flash clock */ - kClockClkoutSelLpoClk = 3U, /*!< LPO clock */ - kClockClkoutSelMcgIrClk = 4U, /*!< MCG out clock */ - kClockClkoutSelRtc32kClk = 5U, /*!< RTC 32k clock */ - kClockClkoutSelOsc0erClk = 6U /*!< OSCERCLK0 clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_clkout_src_kw24d5_t; -#else -} clock_clkout_src_t; -#endif - -/*! @brief SIM RTCCLKOUTSEL clock source select */ -typedef enum _clock_rtcout_src -{ - kClockRtcoutSrc1Hz, /*!< 1Hz clock */ - kClockRtcoutSrc32kHz /*!< 32kHz clock */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} clock_rtcout_src_kw24d5_t; -#else -} clock_rtcout_src_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during stop modes */ -typedef enum _sim_usbsstby_mode -{ - kSimUsbsstbyNoRegulator, /*!< regulator not in standby during Stop modes */ - kSimUsbsstbyWithRegulator /*!< regulator in standby during Stop modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbsstby_mode_kw24d5_t; -#else -} sim_usbsstby_mode_t; -#endif - -/*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */ -typedef enum _sim_usbvstby_mode -{ - kSimUsbvstbyNoRegulator, /*!< regulator not in standby during VLPR and VLPW modes */ - kSimUsbvstbyWithRegulator /*!< regulator in standby during VLPR and VLPW modes */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_usbvstby_mode_kw24d5_t; -#else -} sim_usbvstby_mode_t; -#endif - -/*! @brief SIM ADCx pre-trigger select */ -typedef enum _sim_adc_pretrg_sel -{ - kSimAdcPretrgselA, /*!< Pre-trigger A selected for ADCx */ - kSimAdcPretrgselB /*!< Pre-trigger B selected for ADCx */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_pretrg_sel_kw24d5_t; -#else -} sim_adc_pretrg_sel_t; -#endif - -/*! @brief SIM ADCx trigger select */ -typedef enum _sim_adc_trg_sel -{ - kSimAdcTrgselExt = 0U, /*!< External trigger */ - kSimAdcTrgSelHighSpeedComp0 = 1U, /*!< High speed comparator 0 output */ - kSimAdcTrgSelHighSpeedComp1 = 2U, /*!< High speed comparator 1 output */ - kSimAdcTrgSelPit0 = 4U, /*!< PIT trigger 0 */ - kSimAdcTrgSelPit1 = 5U, /*!< PIT trigger 1 */ - kSimAdcTrgSelPit2 = 6U, /*!< PIT trigger 2 */ - kSimAdcTrgSelPit3 = 7U, /*!< PIT trigger 3 */ - kSimAdcTrgSelFtm0 = 8U, /*!< FTM0 trigger */ - kSimAdcTrgSelFtm1 = 9U, /*!< FTM1 trigger */ - kSimAdcTrgSelFtm2 = 10U, /*!< FTM2 trigger */ - kSimAdcTrgSelRtcAlarm = 12U, /*!< RTC alarm */ - kSimAdcTrgSelRtcSec = 13U, /*!< RTC seconds */ - kSimAdcTrgSelLptimer = 14U /*!< Low-power timer trigger */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_adc_trg_sel_kw24d5_t; -#else -} sim_adc_trg_sel_t; -#endif - -/*! @brief SIM UART receive data source select */ -typedef enum _sim_uart_rxsrc -{ - kSimUartRxsrcPin, /*!< UARTx_RX Pin */ - kSimUartRxsrcCmp0, /*!< CMP0 */ - kSimUartRxsrcCmp1, /*!< CMP1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_rxsrc_kw24d5_t; -#else -} sim_uart_rxsrc_t; -#endif - -/*! @brief SIM UART transmit data source select */ -typedef enum _sim_uart_txsrc -{ - kSimUartTxsrcPin, /*!< UARTx_TX Pin */ - kSimUartTxsrcFtm1, /*!< UARTx_TX pin modulated with FTM1 channel 0 output */ - kSimUartTxsrcFtm2 /*!< UARTx_TX pin modulated with FTM2 channel 0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_uart_txsrc_kw24d5_t; -#else -} sim_uart_txsrc_t; -#endif - -/*! @brief SIM FlexTimer x trigger y select */ -typedef enum _sim_ftm_trg_src -{ - kSimFtmTrgSrc0, /*!< FlexTimer x trigger y select 0 */ - kSimFtmTrgSrc1 /*!< FlexTimer x trigger y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_trg_src_kw24d5_t; -#else -} sim_ftm_trg_src_t; -#endif - -/*! @brief SIM FlexTimer external clock select */ -typedef enum _sim_ftm_clk_sel -{ - kSimFtmClkSel0, /*!< FTM CLKIN0 pin. */ - kSimFtmClkSel1 /*!< FTM CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_clk_sel_kw24d5_t; -#else -} sim_ftm_clk_sel_t; -#endif - -/*! @brief SIM FlexTimer x channel y input capture source select */ -typedef enum _sim_ftm_ch_src -{ - kSimFtmChSrc0, /*!< FlexTimer x channel y input capture source 0. */ - kSimFtmChSrc1, /*!< FlexTimer x channel y input capture source 1. */ - kSimFtmChSrc2, /*!< FlexTimer x channel y input capture source 2. */ - kSimFtmChSrc3 /*!< FlexTimer x channel y input capture source 3. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_ch_src_kw24d5_t; -#else -} sim_ftm_ch_src_t; -#endif - -/*! @brief SIM FlexTimer x Fault y select */ -typedef enum _sim_ftm_flt_sel -{ - kSimFtmFltSel0, /*!< FlexTimer x fault y select 0 */ - kSimFtmFltSel1 /*!< FlexTimer x fault y select 1 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ftm_flt_sel_kw24d5_t; -#else -} sim_ftm_flt_sel_t; -#endif - -/*! @brief SIM Timer/PWM external clock select */ -typedef enum _sim_tpm_clk_sel -{ - kSimTpmClkSel0, /*!< Timer/PWM TPM_CLKIN0 pin. */ - kSimTpmClkSel1 /*!< Timer/PWM TPM_CLKIN1 pin. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_clk_sel_kw24d5_t; -#else -} sim_tpm_clk_sel_t; -#endif - -/*! @brief SIM Timer/PWM x channel y input capture source select */ -typedef enum _sim_tpm_ch_src -{ - kSimTpmChSrc0, /*!< TPMx_CH0 signal */ - kSimTpmChSrc1 /*!< CMP0 output */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_tpm_ch_src_kw24d5_t; -#else -} sim_tpm_ch_src_t; -#endif - -/*! @brief SIM CMT/UART pad drive strength */ -typedef enum _sim_cmtuartpad_strengh -{ - kSimCmtuartSinglePad, /*!< Single-pad drive strength for CMT IRO or UART0_TXD */ - kSimCmtuartDualPad /*!< Dual-pad drive strength for CMT IRO or UART0_TXD */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_cmtuartpad_strengh_kw24d5_t; -#else -} sim_cmtuartpad_strengh_t; -#endif - -/*! @brief SIM PTD7 pad drive strength */ -typedef enum _sim_ptd7pad_strengh -{ - kSimPtd7padSinglePad, /*!< Single-pad drive strength for PTD7 */ - kSimPtd7padDualPad /*!< Dual-pad drive strength for PTD7 */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_ptd7pad_strengh_kw24d5_t; -#else -} sim_ptd7pad_strengh_t; -#endif - - -/*! @brief SIM SCGC bit index. */ -#define FSL_SIM_SCGC_BIT(SCGCx, n) (((SCGCx-1U)<<5U) + n) - -/*! @brief Clock gate name used for SIM_HAL_EnableClock/SIM_HAL_DisableClock. */ -typedef enum _sim_clock_gate_name -{ - kSimClockGateEwm0 = FSL_SIM_SCGC_BIT(4U, 1U), - kSimClockGateCmt0 = FSL_SIM_SCGC_BIT(4U, 2U), - kSimClockGateI2c0 = FSL_SIM_SCGC_BIT(4U, 6U), - kSimClockGateI2c1 = FSL_SIM_SCGC_BIT(4U, 7U), - kSimClockGateUart0 = FSL_SIM_SCGC_BIT(4U, 10U), - kSimClockGateUart1 = FSL_SIM_SCGC_BIT(4U, 11U), - kSimClockGateUart2 = FSL_SIM_SCGC_BIT(4U, 12U), - kSimClockGateUart3 = FSL_SIM_SCGC_BIT(4U, 13U), - kSimClockGateUsbfs0 = FSL_SIM_SCGC_BIT(4U, 18U), - kSimClockGateCmp = FSL_SIM_SCGC_BIT(4U, 19U), - kSimClockGateVref0 = FSL_SIM_SCGC_BIT(4U, 20U), - kSimClockGateLptmr0 = FSL_SIM_SCGC_BIT(5U, 0U), - kSimClockGatePortA = FSL_SIM_SCGC_BIT(5U, 9U), - kSimClockGatePortB = FSL_SIM_SCGC_BIT(5U, 10U), - kSimClockGatePortC = FSL_SIM_SCGC_BIT(5U, 11U), - kSimClockGatePortD = FSL_SIM_SCGC_BIT(5U, 12U), - kSimClockGatePortE = FSL_SIM_SCGC_BIT(5U, 13U), - kSimClockGateFtf0 = FSL_SIM_SCGC_BIT(6U, 0U), - kSimClockGateDmamux0 = FSL_SIM_SCGC_BIT(6U, 1U), - kSimClockGateRnga0 = FSL_SIM_SCGC_BIT(6U, 9U), - kSimClockGateSpi0 = FSL_SIM_SCGC_BIT(6U, 12U), - kSimClockGateSpi1 = FSL_SIM_SCGC_BIT(6U, 13U), - kSimClockGateSai0 = FSL_SIM_SCGC_BIT(6U, 15U), - kSimClockGateCrc0 = FSL_SIM_SCGC_BIT(6U, 18U), - kSimClockGateUsbdcd0 = FSL_SIM_SCGC_BIT(6U, 21U), - kSimClockGatePdb0 = FSL_SIM_SCGC_BIT(6U, 22U), - kSimClockGatePit0 = FSL_SIM_SCGC_BIT(6U, 23U), - kSimClockGateFtm0 = FSL_SIM_SCGC_BIT(6U, 24U), - kSimClockGateFtm1 = FSL_SIM_SCGC_BIT(6U, 25U), - kSimClockGateFtm2 = FSL_SIM_SCGC_BIT(6U, 26U), - kSimClockGateAdc0 = FSL_SIM_SCGC_BIT(6U, 27U), - kSimClockGateRtc0 = FSL_SIM_SCGC_BIT(6U, 29U), - kSimClockGateDac0 = FSL_SIM_SCGC_BIT(6U, 31U), - kSimClockGateDma0 = FSL_SIM_SCGC_BIT(7U, 1U), -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_clock_gate_name_kw24d5_t; -#else -} sim_clock_gate_name_t; -#endif - - -/*! @} */ -/******************************************************************************* - * API - ******************************************************************************/ - - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @addtogroup sim_hal - * @{ - */ - - -/*! - * @brief Enable the clock for specific module. - * - * This function enables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to enable. - */ -static inline void SIM_HAL_EnableClock(SIM_Type* base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 1U); -} - -/*! - * @brief Disable the clock for specific module. - * - * This function disables the clock for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to disable. - */ -static inline void SIM_HAL_DisableClock(SIM_Type* base, sim_clock_gate_name_t name) -{ - SIM_BWR_SCGC_BIT(base, name, 0U); -} - -/*! - * @brief Get the the clock gate state for specific module. - * - * This function will get the clock gate state for specific module. - * - * @param base Base address for current SIM instance. - * @param name Name of the module to get. - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool SIM_HAL_GetGateCmd(SIM_Type* base, sim_clock_gate_name_t name) -{ - return (bool)SIM_BRD_SCGC_BIT(base, name); -} - - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetUsbfsSrc(SIM_Type* base, - uint32_t instance, - clock_usbfs_src_t setting) -{ - SIM_BWR_SOPT2_USBSRC(base, setting); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param base Base address for current SIM instance. - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_HAL_GetUsbfsSrc(SIM_Type* base, - uint32_t instance) -{ - return (clock_usbfs_src_t)SIM_BRD_SOPT2_USBSRC(base); -} - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetExternalRefClock32kSrc(SIM_Type* base, - clock_er32k_src_t setting) -{ - SIM_BWR_SOPT1_OSC32KSEL(base, setting); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_HAL_GetExternalRefClock32kSrc(SIM_Type* base) -{ - return (clock_er32k_src_t)SIM_BRD_SOPT1_OSC32KSEL(base); -} - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetPllfllSel(SIM_Type* base, - clock_pllfll_sel_t setting) -{ - SIM_BWR_SOPT2_PLLFLLSEL(base, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_HAL_GetPllfllSel(SIM_Type* base) -{ - return (clock_pllfll_sel_t)SIM_BRD_SOPT2_PLLFLLSEL(base); -} - -/*! - * @brief Set debug trace clock selection. - * - * This function sets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetTraceClkSrc(SIM_Type* base, clock_trace_src_t setting) -{ - SIM_BWR_SOPT2_TRACECLKSEL(base, setting); -} - -/*! - * @brief Get debug trace clock selection. - * - * This function gets debug trace clock selection. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_trace_src_t CLOCK_HAL_GetTraceClkSrc(SIM_Type* base) -{ - return (clock_trace_src_t)SIM_BRD_SOPT2_TRACECLKSEL(base); -} - -/*! - * @brief Set CLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetClkOutSel(SIM_Type* base, clock_clkout_src_t setting) -{ - SIM_BWR_SOPT2_CLKOUTSEL(base, setting); -} - -/*! - * @brief Get CLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_clkout_src_t CLOCK_HAL_GetClkOutSel(SIM_Type* base) -{ - return (clock_clkout_src_t)SIM_BRD_SOPT2_CLKOUTSEL(base); -} - -/*! - * @brief Set RTCCLKOUTSEL selection. - * - * This function sets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetRtcClkOutSel(SIM_Type* base, - clock_rtcout_src_t setting) -{ - SIM_BWR_SOPT2_RTCCLKOUTSEL(base, setting); -} - -/*! - * @brief Get RTCCLKOUTSEL selection. - * - * This function gets the selection of the clock to output on the RTC_CLKOUT pin. - * - * @param base Base address for current SIM instance. - * @return Current selection. - */ -static inline clock_rtcout_src_t CLOCK_HAL_GetRtcClkOutSel(SIM_Type* base) -{ - return (clock_rtcout_src_t)SIM_BRD_SOPT2_RTCCLKOUTSEL(base); -} - -/*! - * @brief Set OUTDIV1. - * - * This function sets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv1(SIM_Type* base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV1(base, setting); -} - -/*! - * @brief Get OUTDIV1. - * - * This function gets divide value OUTDIV1. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv1(SIM_Type* base) -{ - return SIM_BRD_CLKDIV1_OUTDIV1(base); -} - -/*! - * @brief Set OUTDIV2. - * - * This function sets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv2(SIM_Type* base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV2(base, setting); -} - -/*! - * @brief Get OUTDIV2. - * - * This function gets divide value OUTDIV2. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv2(SIM_Type* base) -{ - return SIM_BRD_CLKDIV1_OUTDIV2(base); -} - -/*! - * @brief Set OUTDIV4. - * - * This function sets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @param setting The value to set. - */ -static inline void CLOCK_HAL_SetOutDiv4(SIM_Type* base, uint8_t setting) -{ - SIM_BWR_CLKDIV1_OUTDIV4(base, setting); -} - -/*! - * @brief Get OUTDIV4. - * - * This function gets divide value OUTDIV4. - * - * @param base Base address for current SIM instance. - * @return Current divide value. - */ -static inline uint8_t CLOCK_HAL_GetOutDiv4(SIM_Type* base) -{ - return SIM_BRD_CLKDIV1_OUTDIV4(base); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_SetOutDiv(SIM_Type* base, - uint8_t outdiv1, - uint8_t outdiv2, - uint8_t outdiv3, - uint8_t outdiv4); - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param base Base address for current SIM instance. - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -void CLOCK_HAL_GetOutDiv(SIM_Type* base, - uint8_t *outdiv1, - uint8_t *outdiv2, - uint8_t *outdiv3, - uint8_t *outdiv4); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_SetUsbfsDiv(SIM_Type* base, - uint8_t usbdiv, - uint8_t usbfrac); - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param base Base address for current SIM instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -void CLOCK_HAL_GetUsbfsDiv(SIM_Type* base, - uint8_t *usbdiv, - uint8_t *usbfrac); - -/*! - * @brief Gets RAM size. - * - * This function gets the RAM size. The field specifies the amount of system RAM - * available on the device. - * - * @param base Base address for current SIM instance. - * @return size RAM size on the device - */ -static inline uint32_t SIM_HAL_GetRamSize(SIM_Type* base) -{ - return SIM_BRD_SOPT1_RAMSIZE(base); -} - -/*! - * @brief Sets the USB voltage regulator enabled setting. - * - * This function controls whether the USB voltage regulator is enabled. This bit - * can only be written when the SOPT1CFG[URWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable setting - * - true: USB voltage regulator is enabled. - * - false: USB voltage regulator is disabled. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorCmd(SIM_Type* base, bool enable) -{ - SIM_BWR_SOPT1_USBREGEN(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enabled setting. - * - * This function gets the USB voltage regulator enabled setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(SIM_Type* base) -{ - return SIM_BRD_SOPT1_USBREGEN(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the - * SOPT1CFG[USSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and - * VLLS modes. - * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS - * modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type* base, - sim_usbsstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBSSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode setting. - * - * This function gets the USB voltage regulator in a standby mode setting. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode setting - */ -static inline sim_usbsstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(SIM_Type* base) -{ - return (sim_usbsstby_mode_t)SIM_BRD_SOPT1_USBSSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function controls whether the USB voltage regulator is placed in a standby - * mode during the VLPR and the VLPW modes. This bit can only be written when the - * SOPT1CFG[UVSWE] bit is set. - * - * @param base Base address for current SIM instance. - * @param setting USB voltage regulator in standby mode setting - * - 0: USB voltage regulator not in standby during VLPR and VLPW modes. - * - 1: USB voltage regulator in standby during VLPR and VLPW modes. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type* base, - sim_usbvstby_mode_t setting) -{ - SIM_BWR_SOPT1_USBVSTBY(base, setting); -} - -/*! - * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW. - * - * @param base Base address for current SIM instance. - * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW - */ -static inline sim_usbvstby_mode_t SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(SIM_Type* base) -{ - return (sim_usbvstby_mode_t)SIM_BRD_SOPT1_USBVSTBY(base); -} - -/*! - * @brief Sets the USB voltage regulator stop standby write enable setting. - * - * This function controls whether the USB voltage regulator stop standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBSSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator stop standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type* base, bool enable) -{ - SIM_BWR_SOPT1CFG_USSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator stop standby write enable setting. - * - * This function gets the USB voltage regulator stop standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator stop standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(SIM_Type* base) -{ - return SIM_BRD_SOPT1CFG_USSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator VLP standby write enable setting. - * - * This function controls whether USB voltage regulator VLP standby write - * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This - * register bit clears after a write to SOPT1[USBVSTBY]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator VLP standby write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type* base, bool enable) -{ - SIM_BWR_SOPT1CFG_UVSWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator VLP standby write enable setting. - * - * This function gets the USB voltage regulator VLP standby write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if the USB voltage regulator VLP standby write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(SIM_Type* base) -{ - return SIM_BRD_SOPT1CFG_UVSWE(base); -} - -/*! - * @brief Sets the USB voltage regulator enable write enable setting. - * - * This function controls whether the USB voltage regulator write enable - * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written. - * This register bit clears after a write to SOPT1[USBREGEN]. - * - * @param base Base address for current SIM instance. - * @param enable USB voltage regulator enable write enable setting - * - true: SOPT1[USBSSTBY] can be written. - * - false: SOPT1[USBSSTBY] cannot be written. - */ -static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(SIM_Type* base, bool enable) -{ - SIM_BWR_SOPT1CFG_URWE(base, enable ? 1 : 0); -} - -/*! - * @brief Gets the USB voltage regulator enable write enable setting. - * - * This function gets the USB voltage regulator enable write enable setting. - * - * @param base Base address for current SIM instance. - * @return enabled True if USB voltage regulator enable write is enabled. - */ -static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(SIM_Type* base) -{ - return SIM_BRD_SOPT1CFG_URWE(base); -} - -/*! - * @brief Sets the PTD7 pad drive strength setting. - * - * This function controls the output drive strength of the PTD7 pin by selecting - * either one or two pads to drive it. - * - * @param base Base address for current SIM instance. - * @param setting PTD7 pad drive strength setting - * - 0: Single-pad drive strength for PTD7. - * - 1: Double pad drive strength for PTD7. - */ -static inline void SIM_HAL_SetPtd7PadDriveStrengthMode(SIM_Type* base, - sim_ptd7pad_strengh_t setting) -{ - SIM_BWR_SOPT2_PTD7PAD(base, setting); -} - -/*! - * @brief Gets the PTD7 pad drive strength setting. - * - * This function gets the PTD7 pad drive strength setting. - * - * @param base Base address for current SIM instance. - * @return setting PTD7 pad drive strength setting - */ -static inline sim_ptd7pad_strengh_t SIM_HAL_GetPtd7PadDriveStrengthMode(SIM_Type* base) -{ - return (sim_ptd7pad_strengh_t)SIM_BRD_SOPT2_PTD7PAD(base); -} - -/*! - * @brief Sets the ADCx alternate trigger enable setting. - * - * This function enables/disables the alternative conversion triggers for ADCx. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param enable Enable alternative conversion triggers for ADCx - * - true: Select alternative conversion trigger. - * - false: Select PDB trigger. - */ -void SIM_HAL_SetAdcAlternativeTriggerCmd(SIM_Type* base, - uint32_t instance, - bool enable); - -/*! - * @brief Gets the ADCx alternate trigger enable setting. - * - * This function gets the ADCx alternate trigger enable setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return enabled True if ADCx alternate trigger is enabled - */ -bool SIM_HAL_GetAdcAlternativeTriggerCmd(SIM_Type* base, uint32_t instance); - -/*! - * @brief Sets the ADCx pre-trigger select setting. - * - * This function selects the ADCx pre-trigger source when the alternative - * triggers are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select pre-trigger select setting for ADCx - */ -void SIM_HAL_SetAdcPreTriggerMode(SIM_Type* base, - uint32_t instance, - sim_adc_pretrg_sel_t select); - -/*! - * @brief Gets the ADCx pre-trigger select setting. - * - * This function gets the ADCx pre-trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select ADCx pre-trigger select setting - */ -sim_adc_pretrg_sel_t SIM_HAL_GetAdcPreTriggerMode(SIM_Type* base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting. - * - * This function selects the ADCx trigger source when alternative triggers - * are enabled through ADCxALTTRGEN. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select trigger select setting for ADCx -*/ -void SIM_HAL_SetAdcTriggerMode(SIM_Type* base, - uint32_t instance, - sim_adc_trg_sel_t select); - -/*! - * @brief Gets the ADCx trigger select setting. - * - * This function gets the ADCx trigger select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return ADCx trigger select setting - */ -sim_adc_trg_sel_t SIM_HAL_GetAdcTriggerMode(SIM_Type* base, - uint32_t instance); - -/*! - * @brief Sets the ADCx trigger select setting in one function. - * - * This function sets ADC alternate trigger, pre-trigger mode and trigger mode. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param altTrigEn Alternative trigger enable or not. - * @param preTrigSel Pre-trigger mode. - * @param trigSel Trigger mode. -*/ -void SIM_HAL_SetAdcTriggerModeOneStep(SIM_Type* base, - uint32_t instance, - bool altTrigEn, - sim_adc_pretrg_sel_t preTrigSel, - sim_adc_trg_sel_t trigSel); - -/*! - * @brief Sets the UARTx receive data source select setting. - * - * This function selects the source for the UARTx receive data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx receive data - */ -void SIM_HAL_SetUartRxSrcMode(SIM_Type* base, - uint32_t instance, - sim_uart_rxsrc_t select); - -/*! - * @brief Gets the UARTx receive data source select setting. - * - * This function gets the UARTx receive data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx receive data source select setting - */ -sim_uart_rxsrc_t SIM_HAL_GetUartRxSrcMode(SIM_Type* base, uint32_t instance); - -/*! - * @brief Sets the UARTx transmit data source select setting. - * - * This function selects the source for the UARTx transmit data. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select the source for the UARTx transmit data - */ -void SIM_HAL_SetUartTxSrcMode(SIM_Type* base, - uint32_t instance, - sim_uart_txsrc_t select); - -/*! - * @brief Gets the UARTx transmit data source select setting. - * - * This function gets the UARTx transmit data source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select UARTx transmit data source select setting - */ -sim_uart_txsrc_t SIM_HAL_GetUartTxSrcMode(SIM_Type* base, uint32_t instance); - -/*! - * @brief Sets the FlexTimer x hardware trigger y source select setting. - * - * This function selects the source of FTMx hardware trigger y. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @param select FlexTimer x hardware trigger y - * - 0: Pre-trigger A selected for ADCx. - * - 1: Pre-trigger B selected for ADCx. - */ -void SIM_HAL_SetFtmTriggerSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t trigger, - sim_ftm_trg_src_t select); - -/*! - * @brief Gets the FlexTimer x hardware trigger y source select setting. - * - * This function gets the FlexTimer x hardware trigger y source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param trigger hardware trigger y - * @return select FlexTimer x hardware trigger y source select setting - */ -sim_ftm_trg_src_t SIM_HAL_GetFtmTriggerSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t trigger); - -/*! - * @brief Sets the FlexTimer x external clock pin select setting. - * - * This function selects the source of FTMx external clock pin select. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param select FTMx external clock pin select - * - 0: FTMx external clock driven by FTM CLKIN0 pin. - * - 1: FTMx external clock driven by FTM CLKIN1 pin. - */ -void SIM_HAL_SetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance, - sim_ftm_clk_sel_t select); - -/*! - * @brief Gets the FlexTimer x external clock pin select setting. - * - * This function gets the FlexTimer x external clock pin select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @return select FlexTimer x external clock pin select setting - */ -sim_ftm_clk_sel_t SIM_HAL_GetFtmExternalClkPinMode(SIM_Type* base, - uint32_t instance); - -/*! - * @brief Sets the FlexTimer x channel y input capture source select setting. - * - * This function selects the FlexTimer x channel y input capture source. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @param select FlexTimer x channel y input capture source - */ -void SIM_HAL_SetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel, - sim_ftm_ch_src_t select); - -/*! - * @brief Gets the FlexTimer x channel y input capture source select setting. - * - * This function gets the FlexTimer x channel y input capture - * source select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param channel FlexTimer channel y - * @return select FlexTimer x channel y input capture source select setting - */ -sim_ftm_ch_src_t SIM_HAL_GetFtmChSrcMode(SIM_Type* base, - uint32_t instance, - uint8_t channel); - -/*! - * @brief Sets the FlexTimer x fault y select setting. - * - * This function sets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @param select FlexTimer x fault y select setting - * - 0: FlexTimer x fault y select 0. - * - 1: FlexTimer x fault y select 1. - */ -void SIM_HAL_SetFtmFaultSelMode(SIM_Type* base, - uint32_t instance, - uint8_t fault, - sim_ftm_flt_sel_t select); - -/*! - * @brief Gets the FlexTimer x fault y select setting. - * - * This function gets the FlexTimer x fault y select setting. - * - * @param base Base address for current SIM instance. - * @param instance device instance. - * @param fault fault y - * @return select FlexTimer x fault y select setting - */ -sim_ftm_flt_sel_t SIM_HAL_GetFtmFaultSelMode(SIM_Type* base, - uint32_t instance, - uint8_t fault); - -/*! - * @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Fam ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Fam ID - */ -static inline uint32_t SIM_HAL_GetFamId(SIM_Type* base) -{ - return SIM_BRD_SDID_FAMID(base); -} - -/*! - * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Pincount ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Pincount ID - */ -static inline uint32_t SIM_HAL_GetPinCntId(SIM_Type* base) -{ - return SIM_BRD_SDID_PINID(base); -} - -/*! - * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID). - * - * This function gets the Kinetis Revision ID in System Device ID register. - * - * @param base Base address for current SIM instance. - * @return id Kinetis Revision ID - */ -static inline uint32_t SIM_HAL_GetRevId(SIM_Type* base) -{ - return SIM_BRD_SDID_REVID(base); -} - -/*! - * @brief Gets the FlexNVM size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size FlexNVM Size - */ -static inline uint32_t SIM_HAL_GetFlexnvmSize(SIM_Type* base) -{ - return SIM_BRD_FCFG1_NVMSIZE(base); -} - -/*! - * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the program flash size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size Program flash Size - */ -static inline uint32_t SIM_HAL_GetProgramFlashSize(SIM_Type* base) -{ - return SIM_BRD_FCFG1_PFSIZE(base); -} - -/*! - * @brief Gets the EEProm size in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the EEProm size in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return size EEProm Size - */ -static inline uint32_t SIM_HAL_GetEepromSize(SIM_Type* base) -{ - return SIM_BRD_FCFG1_EESIZE(base); -} - -/*! - * @brief Gets the FlexNVM partition in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the FlexNVM partition in the Flash Configuration Register1 - * - * @param base Base address for current SIM instance. - * @return setting FlexNVM partition setting - */ -static inline uint32_t SIM_HAL_GetFlexnvmPartition(SIM_Type* base) -{ - return SIM_BRD_FCFG1_DEPART(base); -} - -/*! - * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function sets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param setting Flash Doze setting - */ -static inline void SIM_HAL_SetFlashDoze(SIM_Type* base, uint32_t setting) -{ - SIM_BWR_FCFG1_FLASHDOZE(base, setting); -} - -/*! - * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash Doze in the Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash Doze setting - */ -static inline uint32_t SIM_HAL_GetFlashDoze(SIM_Type* base) -{ - return SIM_BRD_FCFG1_FLASHDOZE(base); -} - -/*! - * @brief Sets the Flash disable setting. - * - * This function sets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @param disable Flash disable setting - */ -static inline void SIM_HAL_SetFlashDisableCmd(SIM_Type* base, bool disable) -{ - SIM_BWR_FCFG1_FLASHDIS(base, disable); -} - -/*! - * @brief Gets the Flash disable setting. - * - * This function gets the Flash disable setting in the - * Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return setting Flash disable setting - */ -static inline bool SIM_HAL_GetFlashDisableCmd(SIM_Type* base) -{ - return (bool)SIM_BRD_FCFG1_FLASHDIS(base); -} - -/*! - * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG). - * - * This function gets the Flash maximum block 0 in Flash Configuration Register 2. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(SIM_Type* base) -{ - return SIM_BRD_FCFG2_MAXADDR0(base); -} - -/*! - * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2. - * - * This function gets the Flash maximum block 1 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return address Flash maximum block 0 address - */ -static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(SIM_Type* base) -{ - return SIM_BRD_FCFG2_MAXADDR1(base); -} - -/*! - * @brief Gets the program flash in the Flash Configuration Register 2. - * - * This function gets the program flash maximum block 0 in Flash Configuration Register 1. - * - * @param base Base address for current SIM instance. - * @return status program flash status - */ -static inline uint32_t SIM_HAL_GetProgramFlashCmd(SIM_Type* base) -{ - return SIM_BRD_FCFG2_PFLSH(base); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ -/*! @}*/ - - -#endif /* __FSL_SIM_HAL_KW24D5_H__*/ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK02F12810/fsl_clock_MK02F12810.c b/KSDK_1.2.0/platform/system/src/clock/MK02F12810/fsl_clock_MK02F12810.c deleted file mode 100755 index 860a021..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK02F12810/fsl_clock_MK02F12810.c +++ /dev/null @@ -1,807 +0,0 @@ -/* - * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - - CLOCK_HAL_SetOutDiv(SIM, 1U, 1U, 0U, 7U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kOsc0ErClockUndiv: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelIrc48M: - freq = CPU_INTERNAL_IRC_48M; - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq - * Description : Gets OSC0ERCLKUDIV. - * This function gets the OSC0 external reference undivided frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq() - >> OSC_HAL_GetExternalRefClkDiv(g_oscBase[0]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG); - } - else - { - return CLOCK_SYS_GetCoreClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClkUndiv: /* OSC0ERCLKUDIV clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK02F12810/fsl_clock_MK02F12810.h b/KSDK_1.2.0/platform/system/src/clock/MK02F12810/fsl_clock_MK02F12810.h deleted file mode 100644 index e4947fb..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK02F12810/fsl_clock_MK02F12810.h +++ /dev/null @@ -1,1116 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_K02F12810_H__) -#define __FSL_CLOCK_K02F12810_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k02f12810*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 -/*! @brief FTM external clock frequency. */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k02f12810_t; -#else -} sim_config_t; -#endif - -/*! @} */ -/*! @addtogroup clock_manager */ -/*! @{ */ -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets the OSC0ERCLK_UNDIV frequency. - * - * This function gets the undivided OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void); - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets ADC alternate 2 clock frequency. - * - * This function gets the ADC alternate 2 clock frequency (ALTCLK2). - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAlt2Freq(uint32_t instance) -{ - return CPU_INTERNAL_IRC_48M; -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_K02F12810_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK10D10/fsl_clock_MK10D10.c b/KSDK_1.2.0/platform/system/src/clock/MK10D10/fsl_clock_MK10D10.c deleted file mode 100755 index 74bc257..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK10D10/fsl_clock_MK10D10.c +++ /dev/null @@ -1,1075 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -#if FSL_FEATURE_SOC_ENET_COUNT -uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; /* ENET_1588_CLKIN */ -#endif -uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; /* SDHC_CLKIN */ -#if FSL_FEATURE_SOC_USB_COUNT -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -#endif -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 1U, 4U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlexBusClock: - *frequency = CLOCK_SYS_GetFlexbusFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexbusFreq - * Description : Gets the clock frequency for FLEXBUS module - * This function gets the clock frequency for FLEXBUS module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexbusFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv3(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG) / 2U; - } - else - { - return CLOCK_SYS_GetCoreClockFreq() / 2U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetRmiiFreq - * Description : Gets the clock frequency for ENET module RMII clock. - * This function gets the clock frequency for ENET module RMII clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance) -{ - /* get the sim clock source setting*/ - if (CLOCK_HAL_GetRmiiSrc(SIM, instance) == kClockRmiiSrcExtalClk) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); /* OSCERCLK */ - } - else - { - return g_enet1588ClkInFreq[0]; /* ENET_1588_CLKIN */ - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetTimeStampFreq - * Description : Gets the clock frequency for ENET module TIME clock. - * This function gets the clock frequency for ENET module TIME clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance) -{ - uint32_t freq; - clock_time_src_t src; - - src = CLOCK_HAL_GetTimeSrc(SIM, instance); - - switch(src) - { - case kClockTimeSrcCoreSysClk: /* Core/System clock. */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockTimeSrcPllFllSel: /* FLL/PLL/IRC48M. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTimeSrcOsc0erClk: /* OSCERCLK. */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTimeSrcExt: /* ENET 1588 clock in. */ - freq = g_enet1588ClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - return freq; -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanFreq - * Description : Gets FLEXCAN clock frequency. - * This function gets the FLEXCAN clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc) -{ - if (kClockFlexcanSrcOsc0erClk == flexcanSrc) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} -#endif - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - case 3: - case 4: - case 5: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSdhcFreq - * Description : Gets the clock frequency for SDHC module - * This function gets the clock frequency for SDHC module - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance) -{ - uint32_t freq; - clock_sdhc_src_t src; - - src = CLOCK_HAL_GetSdhcSrc(SIM, instance); - - switch (src) - { - case kClockSdhcSrcCoreSysClk: /* Core/system clock */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockSdhcSrcPllFllSel: /* Clock selected by SOPT2[PLLFLLSEL]. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockSdhcSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSdhcSrcExt: /* External bypass clock (SDHC0_CLKIN) */ - freq = g_sdhcClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0, - kSimClockGateDac1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/* FlexCAN instance table. */ -static const sim_clock_gate_name_t flexcanGateTable[] = -{ - kSimClockGateFlexcan0, - kSimClockGateFlexcan1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFlexcanClock - * Description : Enable the clock for Flexcan module - * This function enables the clock for Flexcan module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - SIM_HAL_EnableClock(SIM, flexcanGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFlexcanClock - * Description : Disable the clock for Flexcan module - * This function disables the clock for Flexcan module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - SIM_HAL_DisableClock(SIM, flexcanGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanGateCmd - * Description : Get the the clock gate state for Flexcan module - * This function will get the clock gate state for Flexcan module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, flexcanGateTable[instance]); -} -#endif - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, - kSimClockGateSpi2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, - kSimClockGateUart3, - kSimClockGateUart4, - kSimClockGateUart5 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK10D10/fsl_clock_MK10D10.h b/KSDK_1.2.0/platform/system/src/clock/MK10D10/fsl_clock_MK10D10.h deleted file mode 100644 index c531cc9..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK10D10/fsl_clock_MK10D10.h +++ /dev/null @@ -1,2048 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_K10D10_H__) -#define __FSL_CLOCK_K10D10_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k10d10*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief ENET external clock source count. */ -#define ENET_EXT_CLK_COUNT 1 -/*! @brief SDHC external clock source count. */ -#define SDHC_EXT_CLK_COUNT 1 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! @brief ENET external clock frequency(ENET_1588_CLKIN) */ -extern uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; -#endif -/*! @brief SDHC external clock frequency(SDHC_CLKIN). */ -extern uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -#endif -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k10d10_t; -#else -} sim_config_t; -#endif - -/*! @} */ -/*! @addtogroup clock_manager*/ -/*! @{*/ -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider3 setting(OUTDIV3). - * - * This function sets divide value OUTDIV3. - * - * @param outdiv3 Outdivider3 setting - */ -static inline void CLOCK_SYS_SetOutDiv3(uint8_t outdiv3) -{ - CLOCK_HAL_SetOutDiv3(SIM, outdiv3); -} - -/*! - * @brief Gets the clock out divider3 setting(OUTDIV3). - * - * This function gets divide value OUTDIV3. - * - * @return Outdivider3 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv3(void) -{ - return CLOCK_HAL_GetOutDiv3(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Gets ethernet RMII clock source. - * - * This function gets the ethernet RMII clock source. - * - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_rmii_src_t CLOCK_SYS_GetEnetRmiiSrc(uint32_t instance) -{ - return CLOCK_HAL_GetRmiiSrc(SIM, instance); -} - -/*! - * @brief Sets ethernet RMII clock source. - * - * This function sets the ethernet RMII clock source. - * - * @param instance module device instance. - * @param rmiiSrc RMII clock source. - */ -static inline void CLOCK_SYS_SetEnetRmiiSrc(uint32_t instance, clock_rmii_src_t rmiiSrc) -{ - CLOCK_HAL_SetRmiiSrc(SIM, instance, rmiiSrc); -} - -/*! - * @brief Gets ethernet RMII clock frequency. - * - * This function gets the ethernet RMII clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance); -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - /*! - * @brief Gets FLEXCAN clock frequency. - * - * This function gets the FLEXCAN clock frequency. - * - * @param instance module device instance - * @param flexcanSrc clock source - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc); -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param instance module device instance. - * @param timeSrc Ethernet timestamp clock source. - */ -static inline void CLOCK_SYS_SetEnetTimeStampSrc(uint32_t instance, clock_time_src_t timeSrc) -{ - CLOCK_HAL_SetTimeSrc(SIM, instance, timeSrc); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param instance IP instance. - * - * @return Current source. - */ -static inline clock_time_src_t CLOCK_SYS_GetEnetTimeStampSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTimeSrc(SIM, instance); -} - -/*! - * @brief Gets ethernet timestamp clock frequency. - * - * This function gets the ethernet timestamp clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance); -#endif - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} -#endif - -/*! - * @brief Gets the clock frequency for SDHC. - * - * This function gets the clock frequency for SDHC. - * @param instance module device instance - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance); - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetSdhcSrc( uint32_t instance, - clock_sdhc_src_t setting) -{ - CLOCK_HAL_SetSdhcSrc(SIM, instance, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_SYS_GetSdhcSrc(uint32_t instance) -{ - return CLOCK_HAL_GetSdhcSrc(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for USB DCD module - * - * This function gets the clock frequency for USB DCD module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetUsbdcdFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -#if FSL_FEATURE_SOC_OPAMP_COUNT -/*! - * @brief Enable the clock for OPAMP module. - * - * This function enables the clock for OPAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableOpampClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateOpamp); -} - -/*! - * @brief Disable the clock for OPAMP module. - * - * This function disables the clock for OPAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableOpampClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateOpamp); -} - -/*! - * @brief Get the the clock gate state for OPAMP module. - * - * This function will get the clock gate state for OPAMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetOpampGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateOpamp); -} -#endif - -#if FSL_FEATURE_SOC_TRIAMP_COUNT -/*! - * @brief Enable the clock for TRIAMP module. - * - * This function enables the clock for TRIAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTriampClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTriamp); -} - -/*! - * @brief Disable the clock for TRIAMP module. - * - * This function disables the clock for TRIAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTriampClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTriamp); -} - -/*! - * @brief Get the the clock gate state for TRIAMP module. - * - * This function will get the clock gate state for TRIAMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTriampGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTriamp); -} -#endif - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for MPU module. - * - * This function enables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableMpuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Disable the clock for MPU module. - * - * This function disables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableMpuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Get the the clock gate state for MPU module. - * - * This function will get the clock gate state for MPU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetMpuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FLEXBUS module. - * - * This function enables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexbusClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Disable the clock for FLEXBUS module. - * - * This function disables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexbusClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Get the the clock gate state for FLEXBUS module. - * - * This function will get the clock gate state for FLEXBUS module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexbusGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -#if FSL_FEATURE_SOC_RNG_COUNT -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} -#endif - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_LCD_COUNT -/*! - * @brief Enable the clock for SLCD module. - * - * This function enables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSlcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Disable the clock for SLCD module. - * - * This function disables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSlcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Get the the clock gate state for SLCD module. - * - * This function will get the clock gate state for SLCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSlcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Gets the frequency for SLCD default clock. - * - * This function gets the frequency for SLCD default clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdDefaultFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets the frequency for SLCD alternate clock. - * - * This function gets the frequency for SLCD alternate clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAltFreq(uint32_t instance) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} -#endif - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for CMT module. - * - * This function enables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmtClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Disable the clock for CMT module. - * - * This function disables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmtClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Get the the clock gate state for CMT module. - * - * This function will get the clock gate state for CMT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmtGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Enable the clock for ENET module. - * - * This function enables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEnetClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Disable the clock for ENET module. - * - * This function disables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEnetClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Get the the clock gate state for ENET module. - * - * This function will get the clock gate state for ENET module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEnetGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEnet0); -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for USBDCD module. - * - * This function enables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Disable the clock for USBDCD module. - * - * This function disables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Get the the clock gate state for USBDCD module. - * - * This function will get the clock gate state for USBDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbdcd0); -} -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance); - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance); -#endif - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for SDHC module. - * - * This function enables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSdhcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Disable the clock for SDHC module. - * - * This function disables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSdhcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Get the the clock gate state for SDHC module. - * - * This function will get the clock gate state for SDHC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSdhcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Enable the clock for TSI module. - * - * This function enables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTsiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Disable the clock for TSI module. - * - * This function disables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTsiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Get the the clock gate state for TSI module. - * - * This function will get the clock gate state for TSI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTsiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Enable the clock for LLWU module. - * - * This function enables the clock for LLWU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLlwuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLlwu0); -} - -/*! - * @brief Disable the clock for LLWU module. - * - * This function disables the clock for LLWU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLlwuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLlwu0); -} - -/*! - * @brief Get the the clock gate state for LLWU module. - * - * This function will get the clock gate state for LLWU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLlwuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLlwu0); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ENET external clock frequency(ENET_1588_CLKIN). - * - * This function sets the ENET external clock frequency (ENET_1588_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetEnetExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < ENET_EXT_CLK_COUNT); - - g_enet1588ClkInFreq[srcInstance] = freq; -} -#endif - -/*! - * @brief Set the SDHC external clock frequency(SDHC_CLKIN). - * - * This function sets the SDHC external clock frequency (SDHC_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetSdhcExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < SDHC_EXT_CLK_COUNT); - - g_sdhcClkInFreq[srcInstance] = freq; -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} -#endif - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_K10D10_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK11DA5/fsl_clock_MK11DA5.c b/KSDK_1.2.0/platform/system/src/clock/MK11DA5/fsl_clock_MK11DA5.c deleted file mode 100755 index 4e8f36b..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK11DA5/fsl_clock_MK11DA5.c +++ /dev/null @@ -1,861 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_osc_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 1U, 4U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG) / 2U; - } - else - { - return CLOCK_SYS_GetCoreClockFreq() / 2U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - case 3: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - case 4: - case 5: - - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, - kSimClockGateUart3 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK11DA5/fsl_clock_MK11DA5.h b/KSDK_1.2.0/platform/system/src/clock/MK11DA5/fsl_clock_MK11DA5.h deleted file mode 100644 index 56bb274..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK11DA5/fsl_clock_MK11DA5.h +++ /dev/null @@ -1,1436 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_K11DA5_H__) -#define __FSL_CLOCK_K11DA5_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k11da5*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k11da5_t; -#else -} sim_config_t; -#endif - -/*! @brief Default clock configuration number. */ -#define CLOCK_CONFIG_NUM 2 - -/*! @brief Clock configuration index for VLPR mode. */ -#define CLOCK_CONFIG_INDEX_FOR_VLPR 0 - -/*! @brief Clock configuration index for RUN mode. */ -#define CLOCK_CONFIG_INDEX_FOR_RUN 1 - -/*! @} */ -/*! @addtogroup clock_manager*/ -/*! @{*/ -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} - - - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for USB DCD module - * - * This function gets the clock frequency for USB DCD module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetUsbdcdFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for CMT module. - * - * This function enables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmtClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Disable the clock for CMT module. - * - * This function disables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmtClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Get the the clock gate state for CMT module. - * - * This function will get the clock gate state for CMT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmtGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for USBDCD module. - * - * This function enables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Disable the clock for USBDCD module. - * - * This function disables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Get the the clock gate state for USBDCD module. - * - * This function will get the clock gate state for USBDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_K11DA5_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK20D10/fsl_clock_MK20D10.c b/KSDK_1.2.0/platform/system/src/clock/MK20D10/fsl_clock_MK20D10.c deleted file mode 100755 index 74bc257..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK20D10/fsl_clock_MK20D10.c +++ /dev/null @@ -1,1075 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -#if FSL_FEATURE_SOC_ENET_COUNT -uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; /* ENET_1588_CLKIN */ -#endif -uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; /* SDHC_CLKIN */ -#if FSL_FEATURE_SOC_USB_COUNT -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -#endif -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 1U, 4U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlexBusClock: - *frequency = CLOCK_SYS_GetFlexbusFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexbusFreq - * Description : Gets the clock frequency for FLEXBUS module - * This function gets the clock frequency for FLEXBUS module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexbusFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv3(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG) / 2U; - } - else - { - return CLOCK_SYS_GetCoreClockFreq() / 2U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetRmiiFreq - * Description : Gets the clock frequency for ENET module RMII clock. - * This function gets the clock frequency for ENET module RMII clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance) -{ - /* get the sim clock source setting*/ - if (CLOCK_HAL_GetRmiiSrc(SIM, instance) == kClockRmiiSrcExtalClk) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); /* OSCERCLK */ - } - else - { - return g_enet1588ClkInFreq[0]; /* ENET_1588_CLKIN */ - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetTimeStampFreq - * Description : Gets the clock frequency for ENET module TIME clock. - * This function gets the clock frequency for ENET module TIME clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance) -{ - uint32_t freq; - clock_time_src_t src; - - src = CLOCK_HAL_GetTimeSrc(SIM, instance); - - switch(src) - { - case kClockTimeSrcCoreSysClk: /* Core/System clock. */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockTimeSrcPllFllSel: /* FLL/PLL/IRC48M. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTimeSrcOsc0erClk: /* OSCERCLK. */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTimeSrcExt: /* ENET 1588 clock in. */ - freq = g_enet1588ClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - return freq; -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanFreq - * Description : Gets FLEXCAN clock frequency. - * This function gets the FLEXCAN clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc) -{ - if (kClockFlexcanSrcOsc0erClk == flexcanSrc) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} -#endif - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - case 3: - case 4: - case 5: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSdhcFreq - * Description : Gets the clock frequency for SDHC module - * This function gets the clock frequency for SDHC module - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance) -{ - uint32_t freq; - clock_sdhc_src_t src; - - src = CLOCK_HAL_GetSdhcSrc(SIM, instance); - - switch (src) - { - case kClockSdhcSrcCoreSysClk: /* Core/system clock */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockSdhcSrcPllFllSel: /* Clock selected by SOPT2[PLLFLLSEL]. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockSdhcSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSdhcSrcExt: /* External bypass clock (SDHC0_CLKIN) */ - freq = g_sdhcClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0, - kSimClockGateDac1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/* FlexCAN instance table. */ -static const sim_clock_gate_name_t flexcanGateTable[] = -{ - kSimClockGateFlexcan0, - kSimClockGateFlexcan1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFlexcanClock - * Description : Enable the clock for Flexcan module - * This function enables the clock for Flexcan module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - SIM_HAL_EnableClock(SIM, flexcanGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFlexcanClock - * Description : Disable the clock for Flexcan module - * This function disables the clock for Flexcan module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - SIM_HAL_DisableClock(SIM, flexcanGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanGateCmd - * Description : Get the the clock gate state for Flexcan module - * This function will get the clock gate state for Flexcan module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, flexcanGateTable[instance]); -} -#endif - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, - kSimClockGateSpi2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, - kSimClockGateUart3, - kSimClockGateUart4, - kSimClockGateUart5 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK20D10/fsl_clock_MK20D10.h b/KSDK_1.2.0/platform/system/src/clock/MK20D10/fsl_clock_MK20D10.h deleted file mode 100644 index 0b41237..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK20D10/fsl_clock_MK20D10.h +++ /dev/null @@ -1,2048 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_K20D10_H__) -#define __FSL_CLOCK_K20D10_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k20d10*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief ENET external clock source count. */ -#define ENET_EXT_CLK_COUNT 1 -/*! @brief SDHC external clock source count. */ -#define SDHC_EXT_CLK_COUNT 1 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! @brief ENET external clock frequency(ENET_1588_CLKIN) */ -extern uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; -#endif -/*! @brief SDHC external clock frequency(SDHC_CLKIN). */ -extern uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -#endif -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k20d10_t; -#else -} sim_config_t; -#endif - -/*! @} */ -/*! @addtogroup clock_manager*/ -/*! @{*/ -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider3 setting(OUTDIV3). - * - * This function sets divide value OUTDIV3. - * - * @param outdiv3 Outdivider3 setting - */ -static inline void CLOCK_SYS_SetOutDiv3(uint8_t outdiv3) -{ - CLOCK_HAL_SetOutDiv3(SIM, outdiv3); -} - -/*! - * @brief Gets the clock out divider3 setting(OUTDIV3). - * - * This function gets divide value OUTDIV3. - * - * @return Outdivider3 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv3(void) -{ - return CLOCK_HAL_GetOutDiv3(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Gets ethernet RMII clock source. - * - * This function gets the ethernet RMII clock source. - * - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_rmii_src_t CLOCK_SYS_GetEnetRmiiSrc(uint32_t instance) -{ - return CLOCK_HAL_GetRmiiSrc(SIM, instance); -} - -/*! - * @brief Sets ethernet RMII clock source. - * - * This function sets the ethernet RMII clock source. - * - * @param instance module device instance. - * @param rmiiSrc RMII clock source. - */ -static inline void CLOCK_SYS_SetEnetRmiiSrc(uint32_t instance, clock_rmii_src_t rmiiSrc) -{ - CLOCK_HAL_SetRmiiSrc(SIM, instance, rmiiSrc); -} - -/*! - * @brief Gets ethernet RMII clock frequency. - * - * This function gets the ethernet RMII clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance); -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - /*! - * @brief Gets FLEXCAN clock frequency. - * - * This function gets the FLEXCAN clock frequency. - * - * @param instance module device instance - * @param flexcanSrc clock source - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc); -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param instance module device instance. - * @param timeSrc Ethernet timestamp clock source. - */ -static inline void CLOCK_SYS_SetEnetTimeStampSrc(uint32_t instance, clock_time_src_t timeSrc) -{ - CLOCK_HAL_SetTimeSrc(SIM, instance, timeSrc); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param instance IP instance. - * - * @return Current source. - */ -static inline clock_time_src_t CLOCK_SYS_GetEnetTimeStampSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTimeSrc(SIM, instance); -} - -/*! - * @brief Gets ethernet timestamp clock frequency. - * - * This function gets the ethernet timestamp clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance); -#endif - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} -#endif - -/*! - * @brief Gets the clock frequency for SDHC. - * - * This function gets the clock frequency for SDHC. - * @param instance module device instance - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance); - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetSdhcSrc( uint32_t instance, - clock_sdhc_src_t setting) -{ - CLOCK_HAL_SetSdhcSrc(SIM, instance, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_SYS_GetSdhcSrc(uint32_t instance) -{ - return CLOCK_HAL_GetSdhcSrc(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for USB DCD module - * - * This function gets the clock frequency for USB DCD module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetUsbdcdFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -#if FSL_FEATURE_SOC_OPAMP_COUNT -/*! - * @brief Enable the clock for OPAMP module. - * - * This function enables the clock for OPAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableOpampClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateOpamp); -} - -/*! - * @brief Disable the clock for OPAMP module. - * - * This function disables the clock for OPAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableOpampClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateOpamp); -} - -/*! - * @brief Get the the clock gate state for OPAMP module. - * - * This function will get the clock gate state for OPAMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetOpampGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateOpamp); -} -#endif - -#if FSL_FEATURE_SOC_TRIAMP_COUNT -/*! - * @brief Enable the clock for TRIAMP module. - * - * This function enables the clock for TRIAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTriampClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTriamp); -} - -/*! - * @brief Disable the clock for TRIAMP module. - * - * This function disables the clock for TRIAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTriampClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTriamp); -} - -/*! - * @brief Get the the clock gate state for TRIAMP module. - * - * This function will get the clock gate state for TRIAMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTriampGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTriamp); -} -#endif - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for MPU module. - * - * This function enables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableMpuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Disable the clock for MPU module. - * - * This function disables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableMpuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Get the the clock gate state for MPU module. - * - * This function will get the clock gate state for MPU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetMpuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FLEXBUS module. - * - * This function enables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexbusClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Disable the clock for FLEXBUS module. - * - * This function disables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexbusClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Get the the clock gate state for FLEXBUS module. - * - * This function will get the clock gate state for FLEXBUS module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexbusGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -#if FSL_FEATURE_SOC_RNG_COUNT -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} -#endif - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_LCD_COUNT -/*! - * @brief Enable the clock for SLCD module. - * - * This function enables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSlcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Disable the clock for SLCD module. - * - * This function disables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSlcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Get the the clock gate state for SLCD module. - * - * This function will get the clock gate state for SLCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSlcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Gets the frequency for SLCD default clock. - * - * This function gets the frequency for SLCD default clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdDefaultFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets the frequency for SLCD alternate clock. - * - * This function gets the frequency for SLCD alternate clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAltFreq(uint32_t instance) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} -#endif - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for CMT module. - * - * This function enables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmtClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Disable the clock for CMT module. - * - * This function disables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmtClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Get the the clock gate state for CMT module. - * - * This function will get the clock gate state for CMT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmtGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Enable the clock for ENET module. - * - * This function enables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEnetClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Disable the clock for ENET module. - * - * This function disables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEnetClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Get the the clock gate state for ENET module. - * - * This function will get the clock gate state for ENET module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEnetGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEnet0); -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for USBDCD module. - * - * This function enables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Disable the clock for USBDCD module. - * - * This function disables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Get the the clock gate state for USBDCD module. - * - * This function will get the clock gate state for USBDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbdcd0); -} -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance); - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance); -#endif - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for SDHC module. - * - * This function enables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSdhcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Disable the clock for SDHC module. - * - * This function disables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSdhcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Get the the clock gate state for SDHC module. - * - * This function will get the clock gate state for SDHC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSdhcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Enable the clock for TSI module. - * - * This function enables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTsiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Disable the clock for TSI module. - * - * This function disables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTsiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Get the the clock gate state for TSI module. - * - * This function will get the clock gate state for TSI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTsiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Enable the clock for LLWU module. - * - * This function enables the clock for LLWU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLlwuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLlwu0); -} - -/*! - * @brief Disable the clock for LLWU module. - * - * This function disables the clock for LLWU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLlwuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLlwu0); -} - -/*! - * @brief Get the the clock gate state for LLWU module. - * - * This function will get the clock gate state for LLWU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLlwuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLlwu0); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ENET external clock frequency(ENET_1588_CLKIN). - * - * This function sets the ENET external clock frequency (ENET_1588_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetEnetExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < ENET_EXT_CLK_COUNT); - - g_enet1588ClkInFreq[srcInstance] = freq; -} -#endif - -/*! - * @brief Set the SDHC external clock frequency(SDHC_CLKIN). - * - * This function sets the SDHC external clock frequency (SDHC_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetSdhcExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < SDHC_EXT_CLK_COUNT); - - g_sdhcClkInFreq[srcInstance] = freq; -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} -#endif - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_K20D10_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK21DA5/fsl_clock_MK21DA5.c b/KSDK_1.2.0/platform/system/src/clock/MK21DA5/fsl_clock_MK21DA5.c deleted file mode 100755 index 8ab1d63..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK21DA5/fsl_clock_MK21DA5.c +++ /dev/null @@ -1,891 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_osc_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 1U, 4U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG) / 2U; - } - else - { - return CLOCK_SYS_GetCoreClockFreq() / 2U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} - - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - case 3: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - case 4: - case 5: - - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, - kSimClockGateUart3 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK21DA5/fsl_clock_MK21DA5.h b/KSDK_1.2.0/platform/system/src/clock/MK21DA5/fsl_clock_MK21DA5.h deleted file mode 100644 index 87ff3d1..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK21DA5/fsl_clock_MK21DA5.h +++ /dev/null @@ -1,1462 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_K21DA5_H__) -#define __FSL_CLOCK_K21DA5_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k21da5*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief SDHC external clock source count. */ -#define SDHC_EXT_CLK_COUNT 1 - /*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k21da5_t; -#else -} sim_config_t; -#endif - -/*! @brief Default clock configuration number. */ -#define CLOCK_CONFIG_NUM 2 - -/*! @brief Clock configuration index for VLPR mode. */ -#define CLOCK_CONFIG_INDEX_FOR_VLPR 0 - -/*! @brief Clock configuration index for RUN mode. */ -#define CLOCK_CONFIG_INDEX_FOR_RUN 1 - -/*! @} */ -/*! @addtogroup clock_manager*/ -/*! @{*/ -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} - - - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for USB DCD module - * - * This function gets the clock frequency for USB DCD module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetUsbdcdFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for CMT module. - * - * This function enables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmtClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Disable the clock for CMT module. - * - * This function disables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmtClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Get the the clock gate state for CMT module. - * - * This function will get the clock gate state for CMT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmtGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for USBDCD module. - * - * This function enables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Disable the clock for USBDCD module. - * - * This function disables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Get the the clock gate state for USBDCD module. - * - * This function will get the clock gate state for USBDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_K21DA5_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK21FA12/fsl_clock_MK21FA12.c b/KSDK_1.2.0/platform/system/src/clock/MK21FA12/fsl_clock_MK21FA12.c deleted file mode 100755 index 173f98b..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK21FA12/fsl_clock_MK21FA12.c +++ /dev/null @@ -1,965 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; /* SDHC_CLKIN */ -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 2U, 4U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlexBusClock: - *frequency = CLOCK_SYS_GetFlexbusFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the systen clock frequency. - * This function gets the systen clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexbusFreq - * Description : Gets the clock frequency for FLEXBUS module - * This function gets the clock frequency for FLEXBUS moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexbusFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv3(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG) / 2U; - } - else - { - return CLOCK_SYS_GetCoreClockFreq() / 2U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx prescaler/glitch filter clock frequency. - * This function gets the LPTMRx prescaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanFreq - * Description : Gets FLEXCAN clock frequency. - * This function gets the FLEXCAN clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc) -{ - if (kClockFlexcanSrcOsc0erClk == flexcanSrc) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - case 3: - case 4: - case 5: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSdhcFreq - * Description : Gets the clock frequency for SDHC module - * This function gets the clock frequency for SDHC moudle - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance) -{ - uint32_t freq; - clock_sdhc_src_t src; - - src = CLOCK_HAL_GetSdhcSrc(SIM, instance); - - switch (src) - { - case kClockSdhcSrcCoreSysClk: /* Core/system clock */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockSdhcSrcPllFllSel: /* Clock selected by SOPT2[PLLFLLSEL]. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockSdhcSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSdhcSrcExt: /* External bypass clock (SDHC0_CLKIN) */ - freq = g_sdhcClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0, - kSimClockGateDac1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, - kSimClockGateFtm3 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, - kSimClockGateSpi2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1, - kSimClockGateI2c2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, - kSimClockGateUart3, - kSimClockGateUart4, - kSimClockGateUart5 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK21FA12/fsl_clock_MK21FA12.h b/KSDK_1.2.0/platform/system/src/clock/MK21FA12/fsl_clock_MK21FA12.h deleted file mode 100644 index 9f6aa38..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK21FA12/fsl_clock_MK21FA12.h +++ /dev/null @@ -1,1712 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_MK21FA12_H__) -#define __FSL_CLOCK_MK21FA12_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k21fa12 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/*! @brief SDHC external clock source count. */ -#define SDHC_EXT_CLK_COUNT 1 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -/*! @brief SDHC external clock frequency(SDHC_CLKIN). */ -extern uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k21fa12_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider3 setting(OUTDIV3). - * - * This function sets divide value OUTDIV3. - * - * @param outdiv3 Outdivider3 setting - */ -static inline void CLOCK_SYS_SetOutDiv3(uint8_t outdiv3) -{ - CLOCK_HAL_SetOutDiv3(SIM, outdiv3); -} - -/*! - * @brief Gets the clock out divider3 setting(OUTDIV3). - * - * This function gets divide value OUTDIV3. - * - * @return Outdivider3 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv3(void) -{ - return CLOCK_HAL_GetOutDiv3(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS moduel instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} - - /*! - * @brief Gets FLEXCAN clock frequency. - * - * This function gets the FLEXCAN clock frequency. - * - * @param instance module device instance - * @param flexcanSrc clock source - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc); - -/*! - * @brief Gets the clock frequency for SDHC. - * - * This function gets the clock frequency for SDHC. - * @param instance module device instance - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance); - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetSdhcSrc( uint32_t instance, - clock_sdhc_src_t setting) -{ - CLOCK_HAL_SetSdhcSrc(SIM, instance, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_SYS_GetSdhcSrc(uint32_t instance) -{ - return CLOCK_HAL_GetSdhcSrc(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for USB DCD module - * - * This function gets the clock frequency for USB DCD module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetUsbdcdFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for MPU module. - * - * This function enables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableMpuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Disable the clock for MPU module. - * - * This function disables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableMpuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Get the the clock gate state for MPU module. - * - * This function will get the clock gate state for MPU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetMpuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FLEXBUS module. - * - * This function enables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexbusClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Disable the clock for FLEXBUS module. - * - * This function disables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexbusClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Get the the clock gate state for FLEXBUS module. - * - * This function will get the clock gate state for FLEXBUS module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexbusGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for CMT module. - * - * This function enables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmtClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Disable the clock for CMT module. - * - * This function disables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmtClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Get the the clock gate state for CMT module. - * - * This function will get the clock gate state for CMT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmtGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for USBDCD module. - * - * This function enables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Disable the clock for USBDCD module. - * - * This function disables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Get the the clock gate state for USBDCD module. - * - * This function will get the clock gate state for USBDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexcanClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexcan0); -} - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexcanClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexcan0); -} - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFlexcan0); -} - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for SDHC module. - * - * This function enables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSdhcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Disable the clock for SDHC module. - * - * This function disables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSdhcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Get the the clock gate state for SDHC module. - * - * This function will get the clock gate state for SDHC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSdhcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Deinitialize OSC0. - * - * This function deinitializes OSC0. - */ -void CLOCK_SYS_Osc0Deinit(void); - -/*! - * @brief Set the SDHC external clock frequency(SDHC_CLKIN). - * - * This function sets the SDHC external clock frequency (SDHC_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetSdhcExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < SDHC_EXT_CLK_COUNT); - - g_sdhcClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_MK21FA12_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK22F12810/fsl_clock_MK22F12810.c b/KSDK_1.2.0/platform/system/src/clock/MK22F12810/fsl_clock_MK22F12810.c deleted file mode 100755 index 3e9986b..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK22F12810/fsl_clock_MK22F12810.c +++ /dev/null @@ -1,883 +0,0 @@ -/* - * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - - CLOCK_HAL_SetOutDiv(SIM, 1U, 1U, 0U, 7U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kOsc0ErClockUndiv: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kIrc48mClock: - *frequency = CPU_INTERNAL_IRC_48M; - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelIrc48M: - freq = CPU_INTERNAL_IRC_48M; - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq - * Description : Gets OSC0ERCLKUDIV. - * This function gets the OSC0 external reference undevided frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq() - >> OSC_HAL_GetExternalRefClkDiv(g_oscBase[0]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG); - } - else - { - return CLOCK_SYS_GetCoreClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClkUndiv: /* OSC0ERCLKUDIV clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLpuartFreq - * Description : Gets the clock frequency for LPUART module. - * This function gets the clock frequency for LPUART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance) -{ - clock_lpuart_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetLpuartSrc(SIM, instance); - switch (src) - { - case kClockLpuartSrcPllFllSel: - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockLpuartSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpuartSrcMcgIrClk: - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllFllSel: - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK22F12810/fsl_clock_MK22F12810.h b/KSDK_1.2.0/platform/system/src/clock/MK22F12810/fsl_clock_MK22F12810.h deleted file mode 100644 index 08efded..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK22F12810/fsl_clock_MK22F12810.h +++ /dev/null @@ -1,1450 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_K22F12810_H__) -#define __FSL_CLOCK_K22F12810_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k22f12810*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 -/*! @brief USB external clock frequency. */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -/*! @brief FTM external clock frequency. */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k22f12810_t; -#else -} sim_config_t; -#endif - -/*! @} */ -/*! @addtogroup clock_manager*/ -/*! @{*/ -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets the OSC0ERCLK_UNDIV frequency. - * - * This function gets the undivided OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Gets the clock source for LPUART module - * - * This function gets the clock source for LPUART module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_lpuart_src_t CLOCK_SYS_GetLpuartSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpuartSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for LPUART module - * - * This function sets the clock source for LPUART module. - * @param instance module device instance - * @param lpuartSrc Clock source. - */ -static inline void CLOCK_SYS_SetLpuartSrc(uint32_t instance, clock_lpuart_src_t lpuartSrc) -{ - CLOCK_HAL_SetLpuartSrc(SIM, instance, lpuartSrc); -} - -/*! - * @brief Gets the clock frequency for LPUART module - * - * This function gets the clock frequency for LPUART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets ADC alternate 2 clock frequency. - * - * This function gets the ADC alternate 2 clock frequency (ALTCLK2). - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAlt2Freq(uint32_t instance) -{ - return CPU_INTERNAL_IRC_48M; -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDac0); -} - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDac0); -} - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDac0); -} - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for LPUART module. - * - * This function enables the clock for LPUART module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLpuartClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Disable the clock for LPUART module. - * - * This function disables the clock for LPUART module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLpuartClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Get the the clock gate state for LPUART module. - * - * This function will get the clock gate state for LPUART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLpuartGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_K22F12810_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK22F25612/fsl_clock_MK22F25612.c b/KSDK_1.2.0/platform/system/src/clock/MK22F25612/fsl_clock_MK22F25612.c deleted file mode 100755 index 9722697..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK22F25612/fsl_clock_MK22F25612.c +++ /dev/null @@ -1,889 +0,0 @@ -/* - * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - - CLOCK_HAL_SetOutDiv(SIM, 1U, 3U, 0U, 7U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kOsc0ErClockUndiv: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kIrc48mClock: - *frequency = CPU_INTERNAL_IRC_48M; - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockPllFllSelIrc48M: - freq = CPU_INTERNAL_IRC_48M; - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq - * Description : Gets OSC0ERCLKUDIV. - * This function gets the OSC0 external reference undivided frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq() - >> OSC_HAL_GetExternalRefClkDiv(g_oscBase[0]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG); - } - else - { - return CLOCK_SYS_GetCoreClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClkUndiv: /* OSC0ERCLKUDIV clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLpuartFreq - * Description : Gets the clock frequency for LPUART module. - * This function gets the clock frequency for LPUART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance) -{ - clock_lpuart_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetLpuartSrc(SIM, instance); - switch (src) - { - case kClockLpuartSrcPllFllSel: - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockLpuartSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpuartSrcMcgIrClk: - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllFllSel: - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK22F25612/fsl_clock_MK22F25612.h b/KSDK_1.2.0/platform/system/src/clock/MK22F25612/fsl_clock_MK22F25612.h deleted file mode 100644 index 8e5632b..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK22F25612/fsl_clock_MK22F25612.h +++ /dev/null @@ -1,1486 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_K22F25612_H__) -#define __FSL_CLOCK_K22F25612_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k22f25612*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -/*! @brief USB external clock frequency. */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -/*! @brief FTM external clock frequency. */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k22f25612_t; -#else -} sim_config_t; -#endif - -/*! @} */ -/*! @addtogroup clock_manager*/ -/*! @{*/ -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets the OSC0ERCLK_UNDIV frequency. - * - * This function gets the undivided OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS moduel instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Gets the clock source for LPUART module - * - * This function gets the clock source for LPUART module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_lpuart_src_t CLOCK_SYS_GetLpuartSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpuartSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for LPUART module - * - * This function sets the clock source for LPUART module. - * @param instance module device instance - * @param lpuartSrc Clock source. - */ -static inline void CLOCK_SYS_SetLpuartSrc(uint32_t instance, clock_lpuart_src_t lpuartSrc) -{ - CLOCK_HAL_SetLpuartSrc(SIM, instance, lpuartSrc); -} - -/*! - * @brief Gets the clock frequency for LPUART module - * - * This function gets the clock frequency for LPUART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets ADC alternate 2 clock frequency. - * - * This function gets the ADC alternate 2 clock frequency (ALTCLK2). - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAlt2Freq(uint32_t instance) -{ - return CPU_INTERNAL_IRC_48M; -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDac0); -} - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDac0); -} - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDac0); -} - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for LPUART module. - * - * This function enables the clock for LPUART module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLpuartClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Disable the clock for LPUART module. - * - * This function disables the clock for LPUART module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLpuartClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Get the the clock gate state for LPUART module. - * - * This function will get the clock gate state for LPUART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLpuartGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_K22F25612_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK22F51212/fsl_clock_MK22F51212.c b/KSDK_1.2.0/platform/system/src/clock/MK22F51212/fsl_clock_MK22F51212.c deleted file mode 100755 index 4d51926..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK22F51212/fsl_clock_MK22F51212.c +++ /dev/null @@ -1,954 +0,0 @@ -/* - * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - - CLOCK_HAL_SetOutDiv(SIM, 1U, 3U, 3U, 7U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlexBusClock: - *frequency = CLOCK_SYS_GetFlexbusFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kOsc0ErClockUndiv: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kIrc48mClock: - *frequency = CPU_INTERNAL_IRC_48M; - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexbusFreq - * Description : Gets the clock frequency for FLEXBUS module - * This function gets the clock frequency for FLEXBUS module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexbusFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv3(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockPllFllSelIrc48M: - freq = CPU_INTERNAL_IRC_48M; - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq - * Description : Gets OSC0ERCLKUDIV. - * This function gets the OSC0 external reference undivided frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq() - >> OSC_HAL_GetExternalRefClkDiv(g_oscBase[0]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG); - } - else - { - return CLOCK_SYS_GetCoreClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClkUndiv: /* OSC0ERCLKUDIV clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLpuartFreq - * Description : Gets the clock frequency for LPUART module. - * This function gets the clock frequency for LPUART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance) -{ - clock_lpuart_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetLpuartSrc(SIM, instance); - switch (src) - { - case kClockLpuartSrcPllFllSel: - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockLpuartSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpuartSrcMcgIrClk: - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllFllSel: - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0, - kSimClockGateDac1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, - kSimClockGateFtm3 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK22F51212/fsl_clock_MK22F51212.h b/KSDK_1.2.0/platform/system/src/clock/MK22F51212/fsl_clock_MK22F51212.h deleted file mode 100644 index 99cd708..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK22F51212/fsl_clock_MK22F51212.h +++ /dev/null @@ -1,1545 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_K22F51212_H__) -#define __FSL_CLOCK_K22F51212_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k22f51212 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -/*! @brief USB external clock frequency. */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -/*! @brief FTM external clock frequency. */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k22f51212_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider3 setting(OUTDIV3). - * - * This function sets divide value OUTDIV3. - * - * @param outdiv3 Outdivider3 setting - */ -static inline void CLOCK_SYS_SetOutDiv3(uint8_t outdiv3) -{ - CLOCK_HAL_SetOutDiv3(SIM, outdiv3); -} - -/*! - * @brief Gets the clock out divider3 setting(OUTDIV3). - * - * This function gets divide value OUTDIV3. - * - * @return Outdivider3 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv3(void) -{ - return CLOCK_HAL_GetOutDiv3(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets the OSC0ERCLK_UNDIV frequency. - * - * This function gets the undivided OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Gets the clock source for LPUART module - * - * This function gets the clock source for LPUART module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_lpuart_src_t CLOCK_SYS_GetLpuartSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpuartSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for LPUART module - * - * This function sets the clock source for LPUART module. - * @param instance module device instance - * @param lpuartSrc Clock source. - */ -static inline void CLOCK_SYS_SetLpuartSrc(uint32_t instance, clock_lpuart_src_t lpuartSrc) -{ - CLOCK_HAL_SetLpuartSrc(SIM, instance, lpuartSrc); -} - -/*! - * @brief Gets the clock frequency for LPUART module - * - * This function gets the clock frequency for LPUART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets ADC alternate 2 clock frequency. - * - * This function gets the ADC alternate 2 clock frequency (ALTCLK2). - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAlt2Freq(uint32_t instance) -{ - return CPU_INTERNAL_IRC_48M; -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FLEXBUS module. - * - * This function enables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexbusClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Disable the clock for FLEXBUS module. - * - * This function disables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexbusClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Get the the clock gate state for FLEXBUS module. - * - * This function will get the clock gate state for FLEXBUS module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexbusGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for LPUART module. - * - * This function enables the clock for LPUART module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLpuartClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Disable the clock for LPUART module. - * - * This function disables the clock for LPUART module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLpuartClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Get the the clock gate state for LPUART module. - * - * This function will get the clock gate state for LPUART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLpuartGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_K22F51212_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK24F12/fsl_clock_MK24F12.c b/KSDK_1.2.0/platform/system/src/clock/MK24F12/fsl_clock_MK24F12.c deleted file mode 100755 index af3fe42..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK24F12/fsl_clock_MK24F12.c +++ /dev/null @@ -1,970 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; /* SDHC_CLKIN */ -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 2U, 4U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlexBusClock: - *frequency = CLOCK_SYS_GetFlexbusFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kIrc48mClock: - *frequency = CPU_INTERNAL_IRC_48M; - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexbusFreq - * Description : Gets the clock frequency for FLEXBUS module - * This function gets the clock frequency for FLEXBUS module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexbusFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv3(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockPllFllSelIrc48M: - freq = CPU_INTERNAL_IRC_48M; - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG) / 2U; - } - else - { - return CLOCK_SYS_GetCoreClockFreq() / 2U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanFreq - * Description : Gets FLEXCAN clock frequency. - * This function gets the FLEXCAN clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc) -{ - if (kClockFlexcanSrcOsc0erClk == flexcanSrc) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - case 3: - case 4: - case 5: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSdhcFreq - * Description : Gets the clock frequency for SDHC module - * This function gets the clock frequency for SDHC module - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance) -{ - uint32_t freq; - clock_sdhc_src_t src; - - src = CLOCK_HAL_GetSdhcSrc(SIM, instance); - - switch (src) - { - case kClockSdhcSrcCoreSysClk: /* Core/system clock */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockSdhcSrcPllFllSel: /* Clock selected by SOPT2[PLLFLLSEL]. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockSdhcSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSdhcSrcExt: /* External bypass clock (SDHC0_CLKIN) */ - freq = g_sdhcClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0, - kSimClockGateDac1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, - kSimClockGateFtm3 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, - kSimClockGateSpi2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1, - kSimClockGateI2c2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, - kSimClockGateUart3, - kSimClockGateUart4, - kSimClockGateUart5 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK24F12/fsl_clock_MK24F12.h b/KSDK_1.2.0/platform/system/src/clock/MK24F12/fsl_clock_MK24F12.h deleted file mode 100644 index 1f24dbf..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK24F12/fsl_clock_MK24F12.h +++ /dev/null @@ -1,1703 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_K24F12_H__) -#define __FSL_CLOCK_K24F12_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k24f12*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief SDHC external clock source count. */ -#define SDHC_EXT_CLK_COUNT 1 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -/*! @brief SDHC external clock frequency(SDHC_CLKIN). */ -extern uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k24f12_t; -#else -} sim_config_t; -#endif - -/*! @}*/ -/*! @addtogroup clock_manager*/ -/*! @{*/ -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider3 setting(OUTDIV3). - * - * This function sets divide value OUTDIV3. - * - * @param outdiv3 Outdivider3 setting - */ -static inline void CLOCK_SYS_SetOutDiv3(uint8_t outdiv3) -{ - CLOCK_HAL_SetOutDiv3(SIM, outdiv3); -} - -/*! - * @brief Gets the clock out divider3 setting(OUTDIV3). - * - * This function gets divide value OUTDIV3. - * - * @return Outdivider3 setting - */ - -static inline uint8_t CLOCK_SYS_GetOutDiv3(void) -{ - return CLOCK_HAL_GetOutDiv3(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} - - /*! - * @brief Gets FLEXCAN clock frequency. - * - * This function gets the FLEXCAN clock frequency. - * - * @param instance module device instance - * @param flexcanSrc clock source - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc); - -/*! - * @brief Gets the clock frequency for SDHC. - * - * This function gets the clock frequency for SDHC. - * @param instance module device instance - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance); - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetSdhcSrc( uint32_t instance, - clock_sdhc_src_t setting) -{ - CLOCK_HAL_SetSdhcSrc(SIM, instance, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_SYS_GetSdhcSrc(uint32_t instance) -{ - return CLOCK_HAL_GetSdhcSrc(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for USB DCD module - * - * This function gets the clock frequency for USB DCD module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetUsbdcdFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for MPU module. - * - * This function enables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableMpuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Disable the clock for MPU module. - * - * This function disables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableMpuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Get the the clock gate state for MPU module. - * - * This function will get the clock gate state for MPU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetMpuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FLEXBUS module. - * - * This function enables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexbusClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Disable the clock for FLEXBUS module. - * - * This function disables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexbusClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Get the the clock gate state for FLEXBUS module. - * - * This function will get the clock gate state for FLEXBUS module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexbusGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for CMT module. - * - * This function enables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmtClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Disable the clock for CMT module. - * - * This function disables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmtClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Get the the clock gate state for CMT module. - * - * This function will get the clock gate state for CMT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmtGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for USBDCD module. - * - * This function enables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Disable the clock for USBDCD module. - * - * This function disables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Get the the clock gate state for USBDCD module. - * - * This function will get the clock gate state for USBDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexcanClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexcan0); -} - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexcanClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexcan0); -} - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFlexcan0); -} - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for SDHC module. - * - * This function enables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSdhcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Disable the clock for SDHC module. - * - * This function disables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSdhcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Get the the clock gate state for SDHC module. - * - * This function will get the clock gate state for SDHC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSdhcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Set the SDHC external clock frequency(SDHC_CLKIN). - * - * This function sets the SDHC external clock frequency(SDHC_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ - static inline void CLOCK_SYS_SetSdhcExternalFreq(uint32_t srcInstance, uint32_t freq) - { - assert(srcInstance < SDHC_EXT_CLK_COUNT); - - g_sdhcClkInFreq[srcInstance] = freq; - } - -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency(USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ - static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) - { - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; - } - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency(FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ - static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) - { - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; - } - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_K24F12_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK24F25612/fsl_clock_MK24F25612.c b/KSDK_1.2.0/platform/system/src/clock/MK24F25612/fsl_clock_MK24F25612.c deleted file mode 100755 index dd52f9d..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK24F25612/fsl_clock_MK24F25612.c +++ /dev/null @@ -1,900 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - /* system/core clock < 120M, bus clock < 60M; */ - /* flash clock < 25M; */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 2U, 4U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kIrc48mClock: - *frequency = CPU_INTERNAL_IRC_48M; - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockPllFllSelIrc48M: - freq = CPU_INTERNAL_IRC_48M; - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG); - } - else - { - return CLOCK_SYS_GetCoreClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - case 3: - case 4: - case 5: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, - kSimClockGateFtm3 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, - kSimClockGateSpi2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1, - kSimClockGateI2c2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, - kSimClockGateUart3, - kSimClockGateUart4, - kSimClockGateUart5 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK24F25612/fsl_clock_MK24F25612.h b/KSDK_1.2.0/platform/system/src/clock/MK24F25612/fsl_clock_MK24F25612.h deleted file mode 100644 index 96fb12d..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK24F25612/fsl_clock_MK24F25612.h +++ /dev/null @@ -1,1467 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_K24F25612_H__) -#define __FSL_CLOCK_K24F25612_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k24f25612*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k24f25612_t; -#else -} sim_config_t; -#endif - -/*! @} */ -/*! @addtogroup clock_manager*/ -/*! @{*/ -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for USB DCD module - * - * This function gets the clock frequency for USB DCD module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetUsbdcdFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for CMT module. - * - * This function enables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmtClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Disable the clock for CMT module. - * - * This function disables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmtClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Get the the clock gate state for CMT module. - * - * This function will get the clock gate state for CMT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmtGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for USBDCD module. - * - * This function enables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Disable the clock for USBDCD module. - * - * This function disables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Get the the clock gate state for USBDCD module. - * - * This function will get the clock gate state for USBDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency(USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ - static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) - { - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; - } - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency(FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ - static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) - { - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; - } - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_K24F25612_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK26F18/fsl_clock_MK26F18.c b/KSDK_1.2.0/platform/system/src/clock/MK26F18/fsl_clock_MK26F18.c deleted file mode 100755 index 766bcfe..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK26F18/fsl_clock_MK26F18.c +++ /dev/null @@ -1,1219 +0,0 @@ -/* - * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; /* SDHC_CLKIN */ -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ -uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; /* TPM_CLK */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - CLOCK_HAL_SetPllFllDiv(SIM, simConfig->pllflldiv, simConfig->pllfllfrac); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 3U, 7U, 7U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlexBusClock: - *frequency = CLOCK_SYS_GetFlexbusFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kOsc0ErClockUndiv: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgExtPllClock: - *frequency = CLOCK_HAL_GetExtPllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kIrc48mClock: - *frequency = CPU_INTERNAL_IRC_48M; - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexbusFreq - * Description : Gets the clock frequency for FLEXBUS module - * This function gets the clock frequency for FLEXBUS module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexbusFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv3(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockPllFllSelUsb1pfd: - freq = CLOCK_HAL_GetExtPllClk(MCG); - break; - case kClockPllFllSelIrc48M: - freq = CPU_INTERNAL_IRC_48M; - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllDivClockFreq - * Description : Gets the PLL/FLL clock divided by the fractional divider. - * This function gets the frequency of the PLL/FLL clock divided - * by the fractional divider configured by SIM_CLKDIV3[PLLFLLFRAC, PLLFLLDIV]. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllDivClockFreq(void) -{ - uint32_t freq; - uint8_t pllflldiv, pllfllfrac; - - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetPllFllDiv(SIM, &pllflldiv, &pllfllfrac); - return freq * (pllfllfrac + 1) / (pllflldiv + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq - * Description : Gets OSC0ERCLKUDIV. - * This function gets the OSC0 external reference undivided frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq() - >> OSC_HAL_GetExternalRefClkDiv(g_oscBase[0]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - uint32_t freq; - uint8_t tracediv, tracefrac; - - if (kClockTraceSrcMcgoutClkDiv == src) - { - freq = CLOCK_HAL_GetOutClk(MCG); - CLOCK_HAL_GetTraceDiv(SIM, &tracediv, &tracefrac); - return freq * (tracefrac + 1) / (tracediv + 1); - } - else - { - freq = CLOCK_SYS_GetCoreClockFreq(); - } - return freq / 2U; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClkUndiv: /* OSC0ERCLKUDIV clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmfFreq - * Description : Gets the clock frequency for TPM module. - * This function gets the clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance) -{ - uint32_t freq; - clock_tpm_src_t src; - - src = CLOCK_HAL_GetTpmSrc(SIM, instance); - - switch(src) - { - case kClockTpmSrcPllFllSelDiv: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllDivClockFreq(); - break; - case kClockTpmSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTpmSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmExternalFreq - * Description : Gets the external clock frequency for TPM module. - * This function gets the external clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance) -{ - sim_tpm_clk_sel_t src = CLOCK_SYS_GetTpmExternalSrc(instance); - - if (kSimTpmClkSel0 == src) - { - return g_tpmClkFreq[0]; - } - else - { - return g_tpmClkFreq[1]; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLpuartFreq - * Description : Gets the clock frequency for LPUART module. - * This function gets the clock frequency for LPUART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance) -{ - clock_lpuart_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetLpuartSrc(SIM, instance); - switch (src) - { - case kClockLpuartSrcPllFllSel: - freq = CLOCK_SYS_GetPllFllDivClockFreq(); - break; - case kClockLpuartSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpuartSrcMcgIrClk: - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbhsSlowClockFreq - * Description : Gets the slow clock frequency for USB HS/USB PHY module. - * This function gets the clock frequency for USB HS/USB PHY module, - * used to detect wakeup and resume events. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbhsSlowClockFreq(uint32_t instance) { - - if (CLOCK_HAL_GetUsbhsSlowClockSrc(SIM, instance) == kClockUsbhsSlowClkSrcMcgIrClk) - { - return CLOCK_SYS_GetInternalRefClockFreq(); /* MCGIRCLK */ - } - else - { - return CLOCK_SYS_GetRtcFreq(0U); /* RTC 32.768kHz clock */ - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanFreq - * Description : Gets FLEXCAN clock frequency. - * This function gets the FLEXCAN clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc) -{ - if (kClockFlexcanSrcOsc0erClk == flexcanSrc) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - case 3: - case 4: - case 5: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSdhcFreq - * Description : Gets the clock frequency for SDHC module - * This function gets the clock frequency for SDHC moudle - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance) -{ - uint32_t freq; - clock_sdhc_src_t src; - - src = CLOCK_HAL_GetSdhcSrc(SIM, instance); - - switch (src) - { - case kClockSdhcSrcCoreSysClk: /* Core/system clock */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockSdhcSrcPllFllSel: /* Clock selected by SOPT2[PLLFLLSEL]. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockSdhcSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSdhcSrcExt: /* External bypass clock (SDHC0_CLKIN) */ - freq = g_sdhcClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllFllSel: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0, - kSimClockGateDac1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, - kSimClockGateFtm3 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t canGateTable[] = -{ - kSimClockGateFlexcan0, - kSimClockGateFlexcan1 -}; -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFlexcanClock - * Description : Enable the clock for FLEXCAN module - * This function enables the clock for FLEXCAN module. - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(canGateTable)/sizeof(canGateTable[0])); - - SIM_HAL_EnableClock(SIM, canGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFlexcanClock - * Description : Disable the clock for FLEXCAN module - * This function disables the clock for FLEXCAN module. - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(canGateTable)/sizeof(canGateTable[0])); - - SIM_HAL_DisableClock(SIM, canGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanGateCmd - * Description : Get the the clock gate state for FLEXCAN module - * This function will get the clock gate state for FLEXCAN module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance) -{ - assert(instance < sizeof(canGateTable)/sizeof(canGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, canGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, - kSimClockGateSpi2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1, - kSimClockGateI2c2, - kSimClockGateI2c3, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, - kSimClockGateUart3, - kSimClockGateUart4 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/* TPM instance table. */ -static const sim_clock_gate_name_t tpmGateTable[] = -{ - kSimClockGateTpm1, - kSimClockGateTpm2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableTpmClock - * Description : Enable the clock for TPM module - * This function enables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_EnableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableTpmClock - * Description : Disable the clock for TPM module - * This function disables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_DisableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmGateCmd - * Description : Get the the clock gate state for TPM module - * This function will get the clock gate state for TPM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, tpmGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK26F18/fsl_clock_MK26F18.h b/KSDK_1.2.0/platform/system/src/clock/MK26F18/fsl_clock_MK26F18.h deleted file mode 100644 index 635ebae..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK26F18/fsl_clock_MK26F18.h +++ /dev/null @@ -1,2093 +0,0 @@ -/* - * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_K26F18_H__) -#define __FSL_CLOCK_K26F18_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k64f12 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/*! @brief SDHC external clock source count. */ -#define SDHC_EXT_CLK_COUNT 1 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 -/*! @brief TPM external clock source count. */ -#define TPM_EXT_CLK_COUNT 2 - - -/*! @brief SDHC external clock frequency(SDHC_CLKIN). */ -extern uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; -/*! @brief TPM external clock frequency(TPM_CLK). */ -extern uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - uint8_t pllflldiv, pllfllfrac; /*!< PLL/FLL fractional divider setting */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k26f18_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider3 setting(OUTDIV3). - * - * This function sets divide value OUTDIV3. - * - * @param outdiv3 Outdivider3 setting - */ -static inline void CLOCK_SYS_SetOutDiv3(uint8_t outdiv3) -{ - CLOCK_HAL_SetOutDiv3(SIM, outdiv3); -} - -/*! - * @brief Gets the clock out divider3 setting(OUTDIV3). - * - * This function gets divide value OUTDIV3. - * - * @return Outdivider3 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv3(void) -{ - return CLOCK_HAL_GetOutDiv3(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Gets the PLL/FLL clock divided by the fractional divider. - * - * This function gets the frequency of the PLL/FLL clock divided - * by the fractional divider configured by SIM_CLKDIV3[PLLFLLFRAC, PLLFLLDIV]. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllDivClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets the OSC0ERCLK_UNDIV frequency. - * - * This function gets the undivided OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets TPM clock frequency. - * - * This function gets the TPM clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance); - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param instance IP instance. - * @param tpmSrc The value to set. - */ -static inline void CLOCK_SYS_SetTpmSrc(uint32_t instance, clock_tpm_src_t tpmSrc) -{ - CLOCK_HAL_SetTpmSrc(SIM, instance, tpmSrc); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_SYS_GetTpmSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTpmSrc(SIM, instance); -} - -/*! - * @brief Get the TPM external clock source frequency. - * - * This function gets the TPM external clock source frequency. - * - * @param instance IP instance. - * @return TPM external clock frequency. - */ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance); - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @param src TPM external clock source. - */ -static inline void CLOCK_SYS_SetTpmExternalSrc(uint32_t instance, sim_tpm_clk_sel_t src) -{ - SIM_HAL_SetTpmExternalClkPinSelMode(SIM, instance, src); -} - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @return setting Current TPM external clock source. - */ -static inline sim_tpm_clk_sel_t CLOCK_SYS_GetTpmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock source for LPUART module - * - * This function gets the clock source for LPUART module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_lpuart_src_t CLOCK_SYS_GetLpuartSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpuartSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for LPUART module - * - * This function sets the clock source for LPUART module. - * @param instance module device instance - * @param lpuartSrc Clock source. - */ -static inline void CLOCK_SYS_SetLpuartSrc(uint32_t instance, clock_lpuart_src_t lpuartSrc) -{ - CLOCK_HAL_SetLpuartSrc(SIM, instance, lpuartSrc); -} - -/*! - * @brief Gets the clock frequency for LPUART module - * - * This function gets the clock frequency for LPUART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance); - -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS moduel instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Gets the slow clock source for USB HS/USB PHY module - * - * This function gets the slow clock source for USB HS/USB PHY module, - * used to detect wakeup and resume events. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbhs_slowclk_src_t CLOCK_SYS_GetUsbhsSlowClockSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbhsSlowClockSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB HS/USB PHY module - * - * This function sets the clock source for USB HS/USB PHY module, - * used to detect wakeup and resume events. - * @param instance module device instance. - * @param usbhsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbhsSlowClockSrc(uint32_t instance, clock_usbhs_slowclk_src_t usbhsSrc) -{ - CLOCK_HAL_SetUsbhsSlowClockSrc(SIM, instance, usbhsSrc); -} - -/*! - * @brief Gets the slow clock frequency for USB HS/USB PHY module - * - * This function gets the clock frequency for USB HS/USB PHY module, - * used to detect wakeup and resume events. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbhsSlowClockFreq(uint32_t instance); - - /*! - * @brief Gets FLEXCAN clock frequency. - * - * This function gets the FLEXCAN clock frequency. - * - * @param instance module device instance - * @param flexcanSrc clock source - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc); - -/*! - * @brief Gets the clock frequency for SDHC. - * - * This function gets the clock frequency for SDHC. - * @param instance module device instance - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance); - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetSdhcSrc( uint32_t instance, - clock_sdhc_src_t setting) -{ - CLOCK_HAL_SetSdhcSrc(SIM, instance, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_SYS_GetSdhcSrc(uint32_t instance) -{ - return CLOCK_HAL_GetSdhcSrc(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for USB DCD module - * - * This function gets the clock frequency for USB DCD module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetUsbdcdFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for MPU module. - * - * This function enables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableMpuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Disable the clock for MPU module. - * - * This function disables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableMpuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Get the the clock gate state for MPU module. - * - * This function will get the clock gate state for MPU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetMpuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FLEXBUS module. - * - * This function enables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexbusClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Disable the clock for FLEXBUS module. - * - * This function disables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexbusClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Get the the clock gate state for FLEXBUS module. - * - * This function will get the clock gate state for FLEXBUS module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexbusGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Enable the clock for SDRAMC module. - * - * This function enables the clock for SDRAMC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSdramcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSdramc0); -} - -/*! - * @brief Disable the clock for SDRAMC module. - * - * This function disables the clock for SDRAMC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSdramcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSdramc0); -} - -/*! - * @brief Get the the clock gate state for SDRAMC module. - * - * This function will get the clock gate state for SDRAMC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSdramcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSdramc0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - - -/*! - * @brief Enable the clock for TPM module. - * - * This function enables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableTpmClock(uint32_t instance); - -/*! - * @brief Disable the clock for TPM module. - * - * This function disables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableTpmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for TPM module. - * - * This function will get the clock gate state for TPM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for CMT module. - * - * This function enables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmtClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Disable the clock for CMT module. - * - * This function disables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmtClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Get the the clock gate state for CMT module. - * - * This function will get the clock gate state for CMT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmtGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for USBDCD module. - * - * This function enables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Disable the clock for USBDCD module. - * - * This function disables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Get the the clock gate state for USBDCD module. - * - * This function will get the clock gate state for USBDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Enable the clock for USBHS module. - * - * This function enables the clock for USBHS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbhsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbhs0); -} - -/*! - * @brief Disable the clock for USBHS module. - * - * This function disables the clock for USBHS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbhsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbhs0); -} - -/*! - * @brief Get the the clock gate state for USBHS module. - * - * This function will get the clock gate state for USBHS module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbhsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbhs0); -} - -/*! - * @brief Enable the clock for USBPHY module. - * - * This function enables the clock for USBPHY module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbphyClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbhsphy0); -} - -/*! - * @brief Disable the clock for USBPHY module. - * - * This function disables the clock for USBPHY module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbphyClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbhsphy0); -} - -/*! - * @brief Get the the clock gate state for USBPHY module. - * - * This function will get the clock gate state for USBPHY module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbphyGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbhsphy0); -} - -/*! - * @brief Enable the clock for USBHSDCD module. - * - * This function enables the clock for USBHSDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbhsdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbhsdcd0); -} - -/*! - * @brief Disable the clock for USBHSDCD module. - * - * This function disables the clock for USBHSDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbhsdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbhsdcd0); -} - -/*! - * @brief Get the the clock gate state for USBHSDCD module. - * - * This function will get the clock gate state for USBHSDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbhsdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbhsdcd0); -} - -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance); - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for LPUART module. - * - * This function enables the clock for LPUART module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLpuartClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Disable the clock for LPUART module. - * - * This function disables the clock for LPUART module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLpuartClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Get the the clock gate state for LPUART module. - * - * This function will get the clock gate state for LPUART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLpuartGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Enable the clock for SDHC module. - * - * This function enables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSdhcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Disable the clock for SDHC module. - * - * This function disables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSdhcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Get the the clock gate state for SDHC module. - * - * This function will get the clock gate state for SDHC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSdhcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Enable the clock for TSI module. - * - * This function enables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTsiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Disable the clock for TSI module. - * - * This function disables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTsiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Get the the clock gate state for TSI module. - * - * This function will get the clock gate state for TSI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTsiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Set the SDHC external clock frequency(SDHC_CLKIN). - * - * This function sets the SDHC external clock frequency (SDHC_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetSdhcExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < SDHC_EXT_CLK_COUNT); - - g_sdhcClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_K26F18_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK30D10/fsl_clock_MK30D10.c b/KSDK_1.2.0/platform/system/src/clock/MK30D10/fsl_clock_MK30D10.c deleted file mode 100755 index 74bc257..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK30D10/fsl_clock_MK30D10.c +++ /dev/null @@ -1,1075 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -#if FSL_FEATURE_SOC_ENET_COUNT -uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; /* ENET_1588_CLKIN */ -#endif -uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; /* SDHC_CLKIN */ -#if FSL_FEATURE_SOC_USB_COUNT -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -#endif -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 1U, 4U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlexBusClock: - *frequency = CLOCK_SYS_GetFlexbusFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexbusFreq - * Description : Gets the clock frequency for FLEXBUS module - * This function gets the clock frequency for FLEXBUS module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexbusFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv3(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG) / 2U; - } - else - { - return CLOCK_SYS_GetCoreClockFreq() / 2U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetRmiiFreq - * Description : Gets the clock frequency for ENET module RMII clock. - * This function gets the clock frequency for ENET module RMII clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance) -{ - /* get the sim clock source setting*/ - if (CLOCK_HAL_GetRmiiSrc(SIM, instance) == kClockRmiiSrcExtalClk) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); /* OSCERCLK */ - } - else - { - return g_enet1588ClkInFreq[0]; /* ENET_1588_CLKIN */ - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetTimeStampFreq - * Description : Gets the clock frequency for ENET module TIME clock. - * This function gets the clock frequency for ENET module TIME clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance) -{ - uint32_t freq; - clock_time_src_t src; - - src = CLOCK_HAL_GetTimeSrc(SIM, instance); - - switch(src) - { - case kClockTimeSrcCoreSysClk: /* Core/System clock. */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockTimeSrcPllFllSel: /* FLL/PLL/IRC48M. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTimeSrcOsc0erClk: /* OSCERCLK. */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTimeSrcExt: /* ENET 1588 clock in. */ - freq = g_enet1588ClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - return freq; -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanFreq - * Description : Gets FLEXCAN clock frequency. - * This function gets the FLEXCAN clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc) -{ - if (kClockFlexcanSrcOsc0erClk == flexcanSrc) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} -#endif - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - case 3: - case 4: - case 5: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSdhcFreq - * Description : Gets the clock frequency for SDHC module - * This function gets the clock frequency for SDHC module - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance) -{ - uint32_t freq; - clock_sdhc_src_t src; - - src = CLOCK_HAL_GetSdhcSrc(SIM, instance); - - switch (src) - { - case kClockSdhcSrcCoreSysClk: /* Core/system clock */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockSdhcSrcPllFllSel: /* Clock selected by SOPT2[PLLFLLSEL]. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockSdhcSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSdhcSrcExt: /* External bypass clock (SDHC0_CLKIN) */ - freq = g_sdhcClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0, - kSimClockGateDac1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/* FlexCAN instance table. */ -static const sim_clock_gate_name_t flexcanGateTable[] = -{ - kSimClockGateFlexcan0, - kSimClockGateFlexcan1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFlexcanClock - * Description : Enable the clock for Flexcan module - * This function enables the clock for Flexcan module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - SIM_HAL_EnableClock(SIM, flexcanGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFlexcanClock - * Description : Disable the clock for Flexcan module - * This function disables the clock for Flexcan module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - SIM_HAL_DisableClock(SIM, flexcanGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanGateCmd - * Description : Get the the clock gate state for Flexcan module - * This function will get the clock gate state for Flexcan module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, flexcanGateTable[instance]); -} -#endif - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, - kSimClockGateSpi2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, - kSimClockGateUart3, - kSimClockGateUart4, - kSimClockGateUart5 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK30D10/fsl_clock_MK30D10.h b/KSDK_1.2.0/platform/system/src/clock/MK30D10/fsl_clock_MK30D10.h deleted file mode 100644 index b70593d..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK30D10/fsl_clock_MK30D10.h +++ /dev/null @@ -1,2048 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_K30D10_H__) -#define __FSL_CLOCK_K30D10_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k30d10*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief ENET external clock source count. */ -#define ENET_EXT_CLK_COUNT 1 -/*! @brief SDHC external clock source count. */ -#define SDHC_EXT_CLK_COUNT 1 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! @brief ENET external clock frequency(ENET_1588_CLKIN) */ -extern uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; -#endif -/*! @brief SDHC external clock frequency(SDHC_CLKIN). */ -extern uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -#endif -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k30d10_t; -#else -} sim_config_t; -#endif - -/*! @} */ -/*! @addtogroup clock_manager*/ -/*! @{*/ -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider3 setting(OUTDIV3). - * - * This function sets divide value OUTDIV3. - * - * @param outdiv3 Outdivider3 setting - */ -static inline void CLOCK_SYS_SetOutDiv3(uint8_t outdiv3) -{ - CLOCK_HAL_SetOutDiv3(SIM, outdiv3); -} - -/*! - * @brief Gets the clock out divider3 setting(OUTDIV3). - * - * This function gets divide value OUTDIV3. - * - * @return Outdivider3 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv3(void) -{ - return CLOCK_HAL_GetOutDiv3(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Gets ethernet RMII clock source. - * - * This function gets the ethernet RMII clock source. - * - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_rmii_src_t CLOCK_SYS_GetEnetRmiiSrc(uint32_t instance) -{ - return CLOCK_HAL_GetRmiiSrc(SIM, instance); -} - -/*! - * @brief Sets ethernet RMII clock source. - * - * This function sets the ethernet RMII clock source. - * - * @param instance module device instance. - * @param rmiiSrc RMII clock source. - */ -static inline void CLOCK_SYS_SetEnetRmiiSrc(uint32_t instance, clock_rmii_src_t rmiiSrc) -{ - CLOCK_HAL_SetRmiiSrc(SIM, instance, rmiiSrc); -} - -/*! - * @brief Gets ethernet RMII clock frequency. - * - * This function gets the ethernet RMII clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance); -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - /*! - * @brief Gets FLEXCAN clock frequency. - * - * This function gets the FLEXCAN clock frequency. - * - * @param instance module device instance - * @param flexcanSrc clock source - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc); -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param instance module device instance. - * @param timeSrc Ethernet timestamp clock source. - */ -static inline void CLOCK_SYS_SetEnetTimeStampSrc(uint32_t instance, clock_time_src_t timeSrc) -{ - CLOCK_HAL_SetTimeSrc(SIM, instance, timeSrc); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param instance IP instance. - * - * @return Current source. - */ -static inline clock_time_src_t CLOCK_SYS_GetEnetTimeStampSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTimeSrc(SIM, instance); -} - -/*! - * @brief Gets ethernet timestamp clock frequency. - * - * This function gets the ethernet timestamp clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance); -#endif - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} -#endif - -/*! - * @brief Gets the clock frequency for SDHC. - * - * This function gets the clock frequency for SDHC. - * @param instance module device instance - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance); - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetSdhcSrc( uint32_t instance, - clock_sdhc_src_t setting) -{ - CLOCK_HAL_SetSdhcSrc(SIM, instance, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_SYS_GetSdhcSrc(uint32_t instance) -{ - return CLOCK_HAL_GetSdhcSrc(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for USB DCD module - * - * This function gets the clock frequency for USB DCD module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetUsbdcdFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -#if FSL_FEATURE_SOC_OPAMP_COUNT -/*! - * @brief Enable the clock for OPAMP module. - * - * This function enables the clock for OPAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableOpampClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateOpamp); -} - -/*! - * @brief Disable the clock for OPAMP module. - * - * This function disables the clock for OPAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableOpampClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateOpamp); -} - -/*! - * @brief Get the the clock gate state for OPAMP module. - * - * This function will get the clock gate state for OPAMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetOpampGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateOpamp); -} -#endif - -#if FSL_FEATURE_SOC_TRIAMP_COUNT -/*! - * @brief Enable the clock for TRIAMP module. - * - * This function enables the clock for TRIAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTriampClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTriamp); -} - -/*! - * @brief Disable the clock for TRIAMP module. - * - * This function disables the clock for TRIAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTriampClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTriamp); -} - -/*! - * @brief Get the the clock gate state for TRIAMP module. - * - * This function will get the clock gate state for TRIAMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTriampGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTriamp); -} -#endif - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for MPU module. - * - * This function enables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableMpuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Disable the clock for MPU module. - * - * This function disables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableMpuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Get the the clock gate state for MPU module. - * - * This function will get the clock gate state for MPU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetMpuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FLEXBUS module. - * - * This function enables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexbusClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Disable the clock for FLEXBUS module. - * - * This function disables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexbusClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Get the the clock gate state for FLEXBUS module. - * - * This function will get the clock gate state for FLEXBUS module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexbusGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -#if FSL_FEATURE_SOC_RNG_COUNT -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} -#endif - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_LCD_COUNT -/*! - * @brief Enable the clock for SLCD module. - * - * This function enables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSlcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Disable the clock for SLCD module. - * - * This function disables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSlcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Get the the clock gate state for SLCD module. - * - * This function will get the clock gate state for SLCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSlcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Gets the frequency for SLCD default clock. - * - * This function gets the frequency for SLCD default clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdDefaultFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets the frequency for SLCD alternate clock. - * - * This function gets the frequency for SLCD alternate clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAltFreq(uint32_t instance) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} -#endif - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for CMT module. - * - * This function enables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmtClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Disable the clock for CMT module. - * - * This function disables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmtClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Get the the clock gate state for CMT module. - * - * This function will get the clock gate state for CMT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmtGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Enable the clock for ENET module. - * - * This function enables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEnetClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Disable the clock for ENET module. - * - * This function disables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEnetClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Get the the clock gate state for ENET module. - * - * This function will get the clock gate state for ENET module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEnetGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEnet0); -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for USBDCD module. - * - * This function enables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Disable the clock for USBDCD module. - * - * This function disables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Get the the clock gate state for USBDCD module. - * - * This function will get the clock gate state for USBDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbdcd0); -} -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance); - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance); -#endif - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for SDHC module. - * - * This function enables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSdhcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Disable the clock for SDHC module. - * - * This function disables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSdhcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Get the the clock gate state for SDHC module. - * - * This function will get the clock gate state for SDHC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSdhcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Enable the clock for TSI module. - * - * This function enables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTsiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Disable the clock for TSI module. - * - * This function disables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTsiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Get the the clock gate state for TSI module. - * - * This function will get the clock gate state for TSI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTsiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Enable the clock for LLWU module. - * - * This function enables the clock for LLWU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLlwuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLlwu0); -} - -/*! - * @brief Disable the clock for LLWU module. - * - * This function disables the clock for LLWU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLlwuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLlwu0); -} - -/*! - * @brief Get the the clock gate state for LLWU module. - * - * This function will get the clock gate state for LLWU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLlwuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLlwu0); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ENET external clock frequency(ENET_1588_CLKIN). - * - * This function sets the ENET external clock frequency (ENET_1588_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetEnetExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < ENET_EXT_CLK_COUNT); - - g_enet1588ClkInFreq[srcInstance] = freq; -} -#endif - -/*! - * @brief Set the SDHC external clock frequency(SDHC_CLKIN). - * - * This function sets the SDHC external clock frequency (SDHC_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetSdhcExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < SDHC_EXT_CLK_COUNT); - - g_sdhcClkInFreq[srcInstance] = freq; -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} -#endif - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_K30D10_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK40D10/fsl_clock_MK40D10.c b/KSDK_1.2.0/platform/system/src/clock/MK40D10/fsl_clock_MK40D10.c deleted file mode 100755 index 74bc257..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK40D10/fsl_clock_MK40D10.c +++ /dev/null @@ -1,1075 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -#if FSL_FEATURE_SOC_ENET_COUNT -uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; /* ENET_1588_CLKIN */ -#endif -uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; /* SDHC_CLKIN */ -#if FSL_FEATURE_SOC_USB_COUNT -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -#endif -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 1U, 4U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlexBusClock: - *frequency = CLOCK_SYS_GetFlexbusFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexbusFreq - * Description : Gets the clock frequency for FLEXBUS module - * This function gets the clock frequency for FLEXBUS module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexbusFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv3(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG) / 2U; - } - else - { - return CLOCK_SYS_GetCoreClockFreq() / 2U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetRmiiFreq - * Description : Gets the clock frequency for ENET module RMII clock. - * This function gets the clock frequency for ENET module RMII clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance) -{ - /* get the sim clock source setting*/ - if (CLOCK_HAL_GetRmiiSrc(SIM, instance) == kClockRmiiSrcExtalClk) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); /* OSCERCLK */ - } - else - { - return g_enet1588ClkInFreq[0]; /* ENET_1588_CLKIN */ - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetTimeStampFreq - * Description : Gets the clock frequency for ENET module TIME clock. - * This function gets the clock frequency for ENET module TIME clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance) -{ - uint32_t freq; - clock_time_src_t src; - - src = CLOCK_HAL_GetTimeSrc(SIM, instance); - - switch(src) - { - case kClockTimeSrcCoreSysClk: /* Core/System clock. */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockTimeSrcPllFllSel: /* FLL/PLL/IRC48M. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTimeSrcOsc0erClk: /* OSCERCLK. */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTimeSrcExt: /* ENET 1588 clock in. */ - freq = g_enet1588ClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - return freq; -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanFreq - * Description : Gets FLEXCAN clock frequency. - * This function gets the FLEXCAN clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc) -{ - if (kClockFlexcanSrcOsc0erClk == flexcanSrc) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} -#endif - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - case 3: - case 4: - case 5: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSdhcFreq - * Description : Gets the clock frequency for SDHC module - * This function gets the clock frequency for SDHC module - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance) -{ - uint32_t freq; - clock_sdhc_src_t src; - - src = CLOCK_HAL_GetSdhcSrc(SIM, instance); - - switch (src) - { - case kClockSdhcSrcCoreSysClk: /* Core/system clock */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockSdhcSrcPllFllSel: /* Clock selected by SOPT2[PLLFLLSEL]. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockSdhcSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSdhcSrcExt: /* External bypass clock (SDHC0_CLKIN) */ - freq = g_sdhcClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0, - kSimClockGateDac1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/* FlexCAN instance table. */ -static const sim_clock_gate_name_t flexcanGateTable[] = -{ - kSimClockGateFlexcan0, - kSimClockGateFlexcan1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFlexcanClock - * Description : Enable the clock for Flexcan module - * This function enables the clock for Flexcan module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - SIM_HAL_EnableClock(SIM, flexcanGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFlexcanClock - * Description : Disable the clock for Flexcan module - * This function disables the clock for Flexcan module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - SIM_HAL_DisableClock(SIM, flexcanGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanGateCmd - * Description : Get the the clock gate state for Flexcan module - * This function will get the clock gate state for Flexcan module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, flexcanGateTable[instance]); -} -#endif - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, - kSimClockGateSpi2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, - kSimClockGateUart3, - kSimClockGateUart4, - kSimClockGateUart5 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK40D10/fsl_clock_MK40D10.h b/KSDK_1.2.0/platform/system/src/clock/MK40D10/fsl_clock_MK40D10.h deleted file mode 100644 index 6445b7c..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK40D10/fsl_clock_MK40D10.h +++ /dev/null @@ -1,2048 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_K40D10_H__) -#define __FSL_CLOCK_K40D10_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k40d10*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief ENET external clock source count. */ -#define ENET_EXT_CLK_COUNT 1 -/*! @brief SDHC external clock source count. */ -#define SDHC_EXT_CLK_COUNT 1 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! @brief ENET external clock frequency(ENET_1588_CLKIN) */ -extern uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; -#endif -/*! @brief SDHC external clock frequency(SDHC_CLKIN). */ -extern uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -#endif -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k40d10_t; -#else -} sim_config_t; -#endif - -/*! @} */ -/*! @addtogroup clock_manager*/ -/*! @{*/ -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider3 setting(OUTDIV3). - * - * This function sets divide value OUTDIV3. - * - * @param outdiv3 Outdivider3 setting - */ -static inline void CLOCK_SYS_SetOutDiv3(uint8_t outdiv3) -{ - CLOCK_HAL_SetOutDiv3(SIM, outdiv3); -} - -/*! - * @brief Gets the clock out divider3 setting(OUTDIV3). - * - * This function gets divide value OUTDIV3. - * - * @return Outdivider3 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv3(void) -{ - return CLOCK_HAL_GetOutDiv3(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Gets ethernet RMII clock source. - * - * This function gets the ethernet RMII clock source. - * - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_rmii_src_t CLOCK_SYS_GetEnetRmiiSrc(uint32_t instance) -{ - return CLOCK_HAL_GetRmiiSrc(SIM, instance); -} - -/*! - * @brief Sets ethernet RMII clock source. - * - * This function sets the ethernet RMII clock source. - * - * @param instance module device instance. - * @param rmiiSrc RMII clock source. - */ -static inline void CLOCK_SYS_SetEnetRmiiSrc(uint32_t instance, clock_rmii_src_t rmiiSrc) -{ - CLOCK_HAL_SetRmiiSrc(SIM, instance, rmiiSrc); -} - -/*! - * @brief Gets ethernet RMII clock frequency. - * - * This function gets the ethernet RMII clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance); -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - /*! - * @brief Gets FLEXCAN clock frequency. - * - * This function gets the FLEXCAN clock frequency. - * - * @param instance module device instance - * @param flexcanSrc clock source - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc); -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param instance module device instance. - * @param timeSrc Ethernet timestamp clock source. - */ -static inline void CLOCK_SYS_SetEnetTimeStampSrc(uint32_t instance, clock_time_src_t timeSrc) -{ - CLOCK_HAL_SetTimeSrc(SIM, instance, timeSrc); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param instance IP instance. - * - * @return Current source. - */ -static inline clock_time_src_t CLOCK_SYS_GetEnetTimeStampSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTimeSrc(SIM, instance); -} - -/*! - * @brief Gets ethernet timestamp clock frequency. - * - * This function gets the ethernet timestamp clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance); -#endif - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} -#endif - -/*! - * @brief Gets the clock frequency for SDHC. - * - * This function gets the clock frequency for SDHC. - * @param instance module device instance - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance); - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetSdhcSrc( uint32_t instance, - clock_sdhc_src_t setting) -{ - CLOCK_HAL_SetSdhcSrc(SIM, instance, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_SYS_GetSdhcSrc(uint32_t instance) -{ - return CLOCK_HAL_GetSdhcSrc(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for USB DCD module - * - * This function gets the clock frequency for USB DCD module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetUsbdcdFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -#if FSL_FEATURE_SOC_OPAMP_COUNT -/*! - * @brief Enable the clock for OPAMP module. - * - * This function enables the clock for OPAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableOpampClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateOpamp); -} - -/*! - * @brief Disable the clock for OPAMP module. - * - * This function disables the clock for OPAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableOpampClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateOpamp); -} - -/*! - * @brief Get the the clock gate state for OPAMP module. - * - * This function will get the clock gate state for OPAMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetOpampGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateOpamp); -} -#endif - -#if FSL_FEATURE_SOC_TRIAMP_COUNT -/*! - * @brief Enable the clock for TRIAMP module. - * - * This function enables the clock for TRIAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTriampClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTriamp); -} - -/*! - * @brief Disable the clock for TRIAMP module. - * - * This function disables the clock for TRIAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTriampClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTriamp); -} - -/*! - * @brief Get the the clock gate state for TRIAMP module. - * - * This function will get the clock gate state for TRIAMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTriampGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTriamp); -} -#endif - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for MPU module. - * - * This function enables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableMpuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Disable the clock for MPU module. - * - * This function disables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableMpuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Get the the clock gate state for MPU module. - * - * This function will get the clock gate state for MPU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetMpuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FLEXBUS module. - * - * This function enables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexbusClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Disable the clock for FLEXBUS module. - * - * This function disables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexbusClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Get the the clock gate state for FLEXBUS module. - * - * This function will get the clock gate state for FLEXBUS module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexbusGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -#if FSL_FEATURE_SOC_RNG_COUNT -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} -#endif - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_LCD_COUNT -/*! - * @brief Enable the clock for SLCD module. - * - * This function enables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSlcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Disable the clock for SLCD module. - * - * This function disables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSlcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Get the the clock gate state for SLCD module. - * - * This function will get the clock gate state for SLCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSlcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Gets the frequency for SLCD default clock. - * - * This function gets the frequency for SLCD default clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdDefaultFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets the frequency for SLCD alternate clock. - * - * This function gets the frequency for SLCD alternate clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAltFreq(uint32_t instance) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} -#endif - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for CMT module. - * - * This function enables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmtClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Disable the clock for CMT module. - * - * This function disables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmtClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Get the the clock gate state for CMT module. - * - * This function will get the clock gate state for CMT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmtGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Enable the clock for ENET module. - * - * This function enables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEnetClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Disable the clock for ENET module. - * - * This function disables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEnetClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Get the the clock gate state for ENET module. - * - * This function will get the clock gate state for ENET module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEnetGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEnet0); -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for USBDCD module. - * - * This function enables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Disable the clock for USBDCD module. - * - * This function disables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Get the the clock gate state for USBDCD module. - * - * This function will get the clock gate state for USBDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbdcd0); -} -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance); - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance); -#endif - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for SDHC module. - * - * This function enables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSdhcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Disable the clock for SDHC module. - * - * This function disables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSdhcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Get the the clock gate state for SDHC module. - * - * This function will get the clock gate state for SDHC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSdhcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Enable the clock for TSI module. - * - * This function enables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTsiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Disable the clock for TSI module. - * - * This function disables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTsiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Get the the clock gate state for TSI module. - * - * This function will get the clock gate state for TSI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTsiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Enable the clock for LLWU module. - * - * This function enables the clock for LLWU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLlwuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLlwu0); -} - -/*! - * @brief Disable the clock for LLWU module. - * - * This function disables the clock for LLWU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLlwuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLlwu0); -} - -/*! - * @brief Get the the clock gate state for LLWU module. - * - * This function will get the clock gate state for LLWU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLlwuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLlwu0); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ENET external clock frequency(ENET_1588_CLKIN). - * - * This function sets the ENET external clock frequency (ENET_1588_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetEnetExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < ENET_EXT_CLK_COUNT); - - g_enet1588ClkInFreq[srcInstance] = freq; -} -#endif - -/*! - * @brief Set the SDHC external clock frequency(SDHC_CLKIN). - * - * This function sets the SDHC external clock frequency (SDHC_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetSdhcExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < SDHC_EXT_CLK_COUNT); - - g_sdhcClkInFreq[srcInstance] = freq; -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} -#endif - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_K40D10_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK50D10/fsl_clock_MK50D10.c b/KSDK_1.2.0/platform/system/src/clock/MK50D10/fsl_clock_MK50D10.c deleted file mode 100755 index 74bc257..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK50D10/fsl_clock_MK50D10.c +++ /dev/null @@ -1,1075 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -#if FSL_FEATURE_SOC_ENET_COUNT -uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; /* ENET_1588_CLKIN */ -#endif -uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; /* SDHC_CLKIN */ -#if FSL_FEATURE_SOC_USB_COUNT -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -#endif -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 1U, 4U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlexBusClock: - *frequency = CLOCK_SYS_GetFlexbusFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexbusFreq - * Description : Gets the clock frequency for FLEXBUS module - * This function gets the clock frequency for FLEXBUS module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexbusFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv3(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG) / 2U; - } - else - { - return CLOCK_SYS_GetCoreClockFreq() / 2U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetRmiiFreq - * Description : Gets the clock frequency for ENET module RMII clock. - * This function gets the clock frequency for ENET module RMII clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance) -{ - /* get the sim clock source setting*/ - if (CLOCK_HAL_GetRmiiSrc(SIM, instance) == kClockRmiiSrcExtalClk) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); /* OSCERCLK */ - } - else - { - return g_enet1588ClkInFreq[0]; /* ENET_1588_CLKIN */ - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetTimeStampFreq - * Description : Gets the clock frequency for ENET module TIME clock. - * This function gets the clock frequency for ENET module TIME clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance) -{ - uint32_t freq; - clock_time_src_t src; - - src = CLOCK_HAL_GetTimeSrc(SIM, instance); - - switch(src) - { - case kClockTimeSrcCoreSysClk: /* Core/System clock. */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockTimeSrcPllFllSel: /* FLL/PLL/IRC48M. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTimeSrcOsc0erClk: /* OSCERCLK. */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTimeSrcExt: /* ENET 1588 clock in. */ - freq = g_enet1588ClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - return freq; -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanFreq - * Description : Gets FLEXCAN clock frequency. - * This function gets the FLEXCAN clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc) -{ - if (kClockFlexcanSrcOsc0erClk == flexcanSrc) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} -#endif - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - case 3: - case 4: - case 5: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSdhcFreq - * Description : Gets the clock frequency for SDHC module - * This function gets the clock frequency for SDHC module - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance) -{ - uint32_t freq; - clock_sdhc_src_t src; - - src = CLOCK_HAL_GetSdhcSrc(SIM, instance); - - switch (src) - { - case kClockSdhcSrcCoreSysClk: /* Core/system clock */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockSdhcSrcPllFllSel: /* Clock selected by SOPT2[PLLFLLSEL]. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockSdhcSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSdhcSrcExt: /* External bypass clock (SDHC0_CLKIN) */ - freq = g_sdhcClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0, - kSimClockGateDac1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/* FlexCAN instance table. */ -static const sim_clock_gate_name_t flexcanGateTable[] = -{ - kSimClockGateFlexcan0, - kSimClockGateFlexcan1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFlexcanClock - * Description : Enable the clock for Flexcan module - * This function enables the clock for Flexcan module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - SIM_HAL_EnableClock(SIM, flexcanGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFlexcanClock - * Description : Disable the clock for Flexcan module - * This function disables the clock for Flexcan module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - SIM_HAL_DisableClock(SIM, flexcanGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanGateCmd - * Description : Get the the clock gate state for Flexcan module - * This function will get the clock gate state for Flexcan module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, flexcanGateTable[instance]); -} -#endif - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, - kSimClockGateSpi2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, - kSimClockGateUart3, - kSimClockGateUart4, - kSimClockGateUart5 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK50D10/fsl_clock_MK50D10.h b/KSDK_1.2.0/platform/system/src/clock/MK50D10/fsl_clock_MK50D10.h deleted file mode 100644 index 30036f0..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK50D10/fsl_clock_MK50D10.h +++ /dev/null @@ -1,2048 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_K50D10_H__) -#define __FSL_CLOCK_K50D10_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k50d10*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief ENET external clock source count. */ -#define ENET_EXT_CLK_COUNT 1 -/*! @brief SDHC external clock source count. */ -#define SDHC_EXT_CLK_COUNT 1 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! @brief ENET external clock frequency(ENET_1588_CLKIN) */ -extern uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; -#endif -/*! @brief SDHC external clock frequency(SDHC_CLKIN). */ -extern uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -#endif -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k50d10_t; -#else -} sim_config_t; -#endif - -/*! @} */ -/*! @addtogroup clock_manager*/ -/*! @{*/ -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider3 setting(OUTDIV3). - * - * This function sets divide value OUTDIV3. - * - * @param outdiv3 Outdivider3 setting - */ -static inline void CLOCK_SYS_SetOutDiv3(uint8_t outdiv3) -{ - CLOCK_HAL_SetOutDiv3(SIM, outdiv3); -} - -/*! - * @brief Gets the clock out divider3 setting(OUTDIV3). - * - * This function gets divide value OUTDIV3. - * - * @return Outdivider3 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv3(void) -{ - return CLOCK_HAL_GetOutDiv3(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Gets ethernet RMII clock source. - * - * This function gets the ethernet RMII clock source. - * - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_rmii_src_t CLOCK_SYS_GetEnetRmiiSrc(uint32_t instance) -{ - return CLOCK_HAL_GetRmiiSrc(SIM, instance); -} - -/*! - * @brief Sets ethernet RMII clock source. - * - * This function sets the ethernet RMII clock source. - * - * @param instance module device instance. - * @param rmiiSrc RMII clock source. - */ -static inline void CLOCK_SYS_SetEnetRmiiSrc(uint32_t instance, clock_rmii_src_t rmiiSrc) -{ - CLOCK_HAL_SetRmiiSrc(SIM, instance, rmiiSrc); -} - -/*! - * @brief Gets ethernet RMII clock frequency. - * - * This function gets the ethernet RMII clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance); -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - /*! - * @brief Gets FLEXCAN clock frequency. - * - * This function gets the FLEXCAN clock frequency. - * - * @param instance module device instance - * @param flexcanSrc clock source - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc); -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param instance module device instance. - * @param timeSrc Ethernet timestamp clock source. - */ -static inline void CLOCK_SYS_SetEnetTimeStampSrc(uint32_t instance, clock_time_src_t timeSrc) -{ - CLOCK_HAL_SetTimeSrc(SIM, instance, timeSrc); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param instance IP instance. - * - * @return Current source. - */ -static inline clock_time_src_t CLOCK_SYS_GetEnetTimeStampSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTimeSrc(SIM, instance); -} - -/*! - * @brief Gets ethernet timestamp clock frequency. - * - * This function gets the ethernet timestamp clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance); -#endif - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} -#endif - -/*! - * @brief Gets the clock frequency for SDHC. - * - * This function gets the clock frequency for SDHC. - * @param instance module device instance - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance); - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetSdhcSrc( uint32_t instance, - clock_sdhc_src_t setting) -{ - CLOCK_HAL_SetSdhcSrc(SIM, instance, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_SYS_GetSdhcSrc(uint32_t instance) -{ - return CLOCK_HAL_GetSdhcSrc(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for USB DCD module - * - * This function gets the clock frequency for USB DCD module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetUsbdcdFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -#if FSL_FEATURE_SOC_OPAMP_COUNT -/*! - * @brief Enable the clock for OPAMP module. - * - * This function enables the clock for OPAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableOpampClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateOpamp); -} - -/*! - * @brief Disable the clock for OPAMP module. - * - * This function disables the clock for OPAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableOpampClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateOpamp); -} - -/*! - * @brief Get the the clock gate state for OPAMP module. - * - * This function will get the clock gate state for OPAMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetOpampGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateOpamp); -} -#endif - -#if FSL_FEATURE_SOC_TRIAMP_COUNT -/*! - * @brief Enable the clock for TRIAMP module. - * - * This function enables the clock for TRIAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTriampClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTriamp); -} - -/*! - * @brief Disable the clock for TRIAMP module. - * - * This function disables the clock for TRIAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTriampClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTriamp); -} - -/*! - * @brief Get the the clock gate state for TRIAMP module. - * - * This function will get the clock gate state for TRIAMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTriampGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTriamp); -} -#endif - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for MPU module. - * - * This function enables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableMpuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Disable the clock for MPU module. - * - * This function disables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableMpuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Get the the clock gate state for MPU module. - * - * This function will get the clock gate state for MPU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetMpuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FLEXBUS module. - * - * This function enables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexbusClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Disable the clock for FLEXBUS module. - * - * This function disables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexbusClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Get the the clock gate state for FLEXBUS module. - * - * This function will get the clock gate state for FLEXBUS module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexbusGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -#if FSL_FEATURE_SOC_RNG_COUNT -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} -#endif - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_LCD_COUNT -/*! - * @brief Enable the clock for SLCD module. - * - * This function enables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSlcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Disable the clock for SLCD module. - * - * This function disables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSlcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Get the the clock gate state for SLCD module. - * - * This function will get the clock gate state for SLCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSlcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Gets the frequency for SLCD default clock. - * - * This function gets the frequency for SLCD default clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdDefaultFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets the frequency for SLCD alternate clock. - * - * This function gets the frequency for SLCD alternate clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAltFreq(uint32_t instance) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} -#endif - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for CMT module. - * - * This function enables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmtClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Disable the clock for CMT module. - * - * This function disables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmtClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Get the the clock gate state for CMT module. - * - * This function will get the clock gate state for CMT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmtGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Enable the clock for ENET module. - * - * This function enables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEnetClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Disable the clock for ENET module. - * - * This function disables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEnetClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Get the the clock gate state for ENET module. - * - * This function will get the clock gate state for ENET module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEnetGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEnet0); -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for USBDCD module. - * - * This function enables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Disable the clock for USBDCD module. - * - * This function disables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Get the the clock gate state for USBDCD module. - * - * This function will get the clock gate state for USBDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbdcd0); -} -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance); - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance); -#endif - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for SDHC module. - * - * This function enables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSdhcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Disable the clock for SDHC module. - * - * This function disables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSdhcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Get the the clock gate state for SDHC module. - * - * This function will get the clock gate state for SDHC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSdhcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Enable the clock for TSI module. - * - * This function enables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTsiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Disable the clock for TSI module. - * - * This function disables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTsiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Get the the clock gate state for TSI module. - * - * This function will get the clock gate state for TSI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTsiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Enable the clock for LLWU module. - * - * This function enables the clock for LLWU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLlwuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLlwu0); -} - -/*! - * @brief Disable the clock for LLWU module. - * - * This function disables the clock for LLWU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLlwuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLlwu0); -} - -/*! - * @brief Get the the clock gate state for LLWU module. - * - * This function will get the clock gate state for LLWU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLlwuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLlwu0); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ENET external clock frequency(ENET_1588_CLKIN). - * - * This function sets the ENET external clock frequency (ENET_1588_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetEnetExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < ENET_EXT_CLK_COUNT); - - g_enet1588ClkInFreq[srcInstance] = freq; -} -#endif - -/*! - * @brief Set the SDHC external clock frequency(SDHC_CLKIN). - * - * This function sets the SDHC external clock frequency (SDHC_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetSdhcExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < SDHC_EXT_CLK_COUNT); - - g_sdhcClkInFreq[srcInstance] = freq; -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} -#endif - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_K50D10_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK51D10/fsl_clock_MK51D10.c b/KSDK_1.2.0/platform/system/src/clock/MK51D10/fsl_clock_MK51D10.c deleted file mode 100755 index 74bc257..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK51D10/fsl_clock_MK51D10.c +++ /dev/null @@ -1,1075 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -#if FSL_FEATURE_SOC_ENET_COUNT -uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; /* ENET_1588_CLKIN */ -#endif -uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; /* SDHC_CLKIN */ -#if FSL_FEATURE_SOC_USB_COUNT -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -#endif -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 1U, 4U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlexBusClock: - *frequency = CLOCK_SYS_GetFlexbusFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexbusFreq - * Description : Gets the clock frequency for FLEXBUS module - * This function gets the clock frequency for FLEXBUS module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexbusFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv3(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG) / 2U; - } - else - { - return CLOCK_SYS_GetCoreClockFreq() / 2U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetRmiiFreq - * Description : Gets the clock frequency for ENET module RMII clock. - * This function gets the clock frequency for ENET module RMII clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance) -{ - /* get the sim clock source setting*/ - if (CLOCK_HAL_GetRmiiSrc(SIM, instance) == kClockRmiiSrcExtalClk) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); /* OSCERCLK */ - } - else - { - return g_enet1588ClkInFreq[0]; /* ENET_1588_CLKIN */ - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetTimeStampFreq - * Description : Gets the clock frequency for ENET module TIME clock. - * This function gets the clock frequency for ENET module TIME clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance) -{ - uint32_t freq; - clock_time_src_t src; - - src = CLOCK_HAL_GetTimeSrc(SIM, instance); - - switch(src) - { - case kClockTimeSrcCoreSysClk: /* Core/System clock. */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockTimeSrcPllFllSel: /* FLL/PLL/IRC48M. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTimeSrcOsc0erClk: /* OSCERCLK. */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTimeSrcExt: /* ENET 1588 clock in. */ - freq = g_enet1588ClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - return freq; -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanFreq - * Description : Gets FLEXCAN clock frequency. - * This function gets the FLEXCAN clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc) -{ - if (kClockFlexcanSrcOsc0erClk == flexcanSrc) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} -#endif - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - case 3: - case 4: - case 5: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSdhcFreq - * Description : Gets the clock frequency for SDHC module - * This function gets the clock frequency for SDHC module - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance) -{ - uint32_t freq; - clock_sdhc_src_t src; - - src = CLOCK_HAL_GetSdhcSrc(SIM, instance); - - switch (src) - { - case kClockSdhcSrcCoreSysClk: /* Core/system clock */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockSdhcSrcPllFllSel: /* Clock selected by SOPT2[PLLFLLSEL]. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockSdhcSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSdhcSrcExt: /* External bypass clock (SDHC0_CLKIN) */ - freq = g_sdhcClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0, - kSimClockGateDac1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/* FlexCAN instance table. */ -static const sim_clock_gate_name_t flexcanGateTable[] = -{ - kSimClockGateFlexcan0, - kSimClockGateFlexcan1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFlexcanClock - * Description : Enable the clock for Flexcan module - * This function enables the clock for Flexcan module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - SIM_HAL_EnableClock(SIM, flexcanGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFlexcanClock - * Description : Disable the clock for Flexcan module - * This function disables the clock for Flexcan module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - SIM_HAL_DisableClock(SIM, flexcanGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanGateCmd - * Description : Get the the clock gate state for Flexcan module - * This function will get the clock gate state for Flexcan module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, flexcanGateTable[instance]); -} -#endif - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, - kSimClockGateSpi2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, - kSimClockGateUart3, - kSimClockGateUart4, - kSimClockGateUart5 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK51D10/fsl_clock_MK51D10.h b/KSDK_1.2.0/platform/system/src/clock/MK51D10/fsl_clock_MK51D10.h deleted file mode 100644 index f4a5057..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK51D10/fsl_clock_MK51D10.h +++ /dev/null @@ -1,2048 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_K51D10_H__) -#define __FSL_CLOCK_K51D10_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k51d10*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief ENET external clock source count. */ -#define ENET_EXT_CLK_COUNT 1 -/*! @brief SDHC external clock source count. */ -#define SDHC_EXT_CLK_COUNT 1 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! @brief ENET external clock frequency(ENET_1588_CLKIN) */ -extern uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; -#endif -/*! @brief SDHC external clock frequency(SDHC_CLKIN). */ -extern uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -#endif -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k51d10_t; -#else -} sim_config_t; -#endif - -/*! @} */ -/*! @addtogroup clock_manager*/ -/*! @{*/ -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider3 setting(OUTDIV3). - * - * This function sets divide value OUTDIV3. - * - * @param outdiv3 Outdivider3 setting - */ -static inline void CLOCK_SYS_SetOutDiv3(uint8_t outdiv3) -{ - CLOCK_HAL_SetOutDiv3(SIM, outdiv3); -} - -/*! - * @brief Gets the clock out divider3 setting(OUTDIV3). - * - * This function gets divide value OUTDIV3. - * - * @return Outdivider3 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv3(void) -{ - return CLOCK_HAL_GetOutDiv3(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Gets ethernet RMII clock source. - * - * This function gets the ethernet RMII clock source. - * - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_rmii_src_t CLOCK_SYS_GetEnetRmiiSrc(uint32_t instance) -{ - return CLOCK_HAL_GetRmiiSrc(SIM, instance); -} - -/*! - * @brief Sets ethernet RMII clock source. - * - * This function sets the ethernet RMII clock source. - * - * @param instance module device instance. - * @param rmiiSrc RMII clock source. - */ -static inline void CLOCK_SYS_SetEnetRmiiSrc(uint32_t instance, clock_rmii_src_t rmiiSrc) -{ - CLOCK_HAL_SetRmiiSrc(SIM, instance, rmiiSrc); -} - -/*! - * @brief Gets ethernet RMII clock frequency. - * - * This function gets the ethernet RMII clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance); -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - /*! - * @brief Gets FLEXCAN clock frequency. - * - * This function gets the FLEXCAN clock frequency. - * - * @param instance module device instance - * @param flexcanSrc clock source - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc); -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param instance module device instance. - * @param timeSrc Ethernet timestamp clock source. - */ -static inline void CLOCK_SYS_SetEnetTimeStampSrc(uint32_t instance, clock_time_src_t timeSrc) -{ - CLOCK_HAL_SetTimeSrc(SIM, instance, timeSrc); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param instance IP instance. - * - * @return Current source. - */ -static inline clock_time_src_t CLOCK_SYS_GetEnetTimeStampSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTimeSrc(SIM, instance); -} - -/*! - * @brief Gets ethernet timestamp clock frequency. - * - * This function gets the ethernet timestamp clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance); -#endif - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} -#endif - -/*! - * @brief Gets the clock frequency for SDHC. - * - * This function gets the clock frequency for SDHC. - * @param instance module device instance - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance); - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetSdhcSrc( uint32_t instance, - clock_sdhc_src_t setting) -{ - CLOCK_HAL_SetSdhcSrc(SIM, instance, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_SYS_GetSdhcSrc(uint32_t instance) -{ - return CLOCK_HAL_GetSdhcSrc(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for USB DCD module - * - * This function gets the clock frequency for USB DCD module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetUsbdcdFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -#if FSL_FEATURE_SOC_OPAMP_COUNT -/*! - * @brief Enable the clock for OPAMP module. - * - * This function enables the clock for OPAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableOpampClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateOpamp); -} - -/*! - * @brief Disable the clock for OPAMP module. - * - * This function disables the clock for OPAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableOpampClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateOpamp); -} - -/*! - * @brief Get the the clock gate state for OPAMP module. - * - * This function will get the clock gate state for OPAMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetOpampGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateOpamp); -} -#endif - -#if FSL_FEATURE_SOC_TRIAMP_COUNT -/*! - * @brief Enable the clock for TRIAMP module. - * - * This function enables the clock for TRIAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTriampClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTriamp); -} - -/*! - * @brief Disable the clock for TRIAMP module. - * - * This function disables the clock for TRIAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTriampClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTriamp); -} - -/*! - * @brief Get the the clock gate state for TRIAMP module. - * - * This function will get the clock gate state for TRIAMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTriampGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTriamp); -} -#endif - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for MPU module. - * - * This function enables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableMpuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Disable the clock for MPU module. - * - * This function disables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableMpuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Get the the clock gate state for MPU module. - * - * This function will get the clock gate state for MPU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetMpuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FLEXBUS module. - * - * This function enables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexbusClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Disable the clock for FLEXBUS module. - * - * This function disables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexbusClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Get the the clock gate state for FLEXBUS module. - * - * This function will get the clock gate state for FLEXBUS module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexbusGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -#if FSL_FEATURE_SOC_RNG_COUNT -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} -#endif - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_LCD_COUNT -/*! - * @brief Enable the clock for SLCD module. - * - * This function enables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSlcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Disable the clock for SLCD module. - * - * This function disables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSlcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Get the the clock gate state for SLCD module. - * - * This function will get the clock gate state for SLCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSlcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Gets the frequency for SLCD default clock. - * - * This function gets the frequency for SLCD default clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdDefaultFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets the frequency for SLCD alternate clock. - * - * This function gets the frequency for SLCD alternate clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAltFreq(uint32_t instance) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} -#endif - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for CMT module. - * - * This function enables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmtClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Disable the clock for CMT module. - * - * This function disables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmtClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Get the the clock gate state for CMT module. - * - * This function will get the clock gate state for CMT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmtGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Enable the clock for ENET module. - * - * This function enables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEnetClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Disable the clock for ENET module. - * - * This function disables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEnetClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Get the the clock gate state for ENET module. - * - * This function will get the clock gate state for ENET module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEnetGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEnet0); -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for USBDCD module. - * - * This function enables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Disable the clock for USBDCD module. - * - * This function disables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Get the the clock gate state for USBDCD module. - * - * This function will get the clock gate state for USBDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbdcd0); -} -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance); - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance); -#endif - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for SDHC module. - * - * This function enables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSdhcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Disable the clock for SDHC module. - * - * This function disables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSdhcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Get the the clock gate state for SDHC module. - * - * This function will get the clock gate state for SDHC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSdhcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Enable the clock for TSI module. - * - * This function enables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTsiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Disable the clock for TSI module. - * - * This function disables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTsiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Get the the clock gate state for TSI module. - * - * This function will get the clock gate state for TSI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTsiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Enable the clock for LLWU module. - * - * This function enables the clock for LLWU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLlwuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLlwu0); -} - -/*! - * @brief Disable the clock for LLWU module. - * - * This function disables the clock for LLWU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLlwuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLlwu0); -} - -/*! - * @brief Get the the clock gate state for LLWU module. - * - * This function will get the clock gate state for LLWU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLlwuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLlwu0); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ENET external clock frequency(ENET_1588_CLKIN). - * - * This function sets the ENET external clock frequency (ENET_1588_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetEnetExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < ENET_EXT_CLK_COUNT); - - g_enet1588ClkInFreq[srcInstance] = freq; -} -#endif - -/*! - * @brief Set the SDHC external clock frequency(SDHC_CLKIN). - * - * This function sets the SDHC external clock frequency (SDHC_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetSdhcExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < SDHC_EXT_CLK_COUNT); - - g_sdhcClkInFreq[srcInstance] = freq; -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} -#endif - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_K51D10_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK52D10/fsl_clock_MK52D10.c b/KSDK_1.2.0/platform/system/src/clock/MK52D10/fsl_clock_MK52D10.c deleted file mode 100755 index 74bc257..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK52D10/fsl_clock_MK52D10.c +++ /dev/null @@ -1,1075 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -#if FSL_FEATURE_SOC_ENET_COUNT -uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; /* ENET_1588_CLKIN */ -#endif -uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; /* SDHC_CLKIN */ -#if FSL_FEATURE_SOC_USB_COUNT -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -#endif -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 1U, 4U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlexBusClock: - *frequency = CLOCK_SYS_GetFlexbusFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexbusFreq - * Description : Gets the clock frequency for FLEXBUS module - * This function gets the clock frequency for FLEXBUS module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexbusFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv3(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG) / 2U; - } - else - { - return CLOCK_SYS_GetCoreClockFreq() / 2U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetRmiiFreq - * Description : Gets the clock frequency for ENET module RMII clock. - * This function gets the clock frequency for ENET module RMII clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance) -{ - /* get the sim clock source setting*/ - if (CLOCK_HAL_GetRmiiSrc(SIM, instance) == kClockRmiiSrcExtalClk) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); /* OSCERCLK */ - } - else - { - return g_enet1588ClkInFreq[0]; /* ENET_1588_CLKIN */ - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetTimeStampFreq - * Description : Gets the clock frequency for ENET module TIME clock. - * This function gets the clock frequency for ENET module TIME clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance) -{ - uint32_t freq; - clock_time_src_t src; - - src = CLOCK_HAL_GetTimeSrc(SIM, instance); - - switch(src) - { - case kClockTimeSrcCoreSysClk: /* Core/System clock. */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockTimeSrcPllFllSel: /* FLL/PLL/IRC48M. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTimeSrcOsc0erClk: /* OSCERCLK. */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTimeSrcExt: /* ENET 1588 clock in. */ - freq = g_enet1588ClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - return freq; -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanFreq - * Description : Gets FLEXCAN clock frequency. - * This function gets the FLEXCAN clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc) -{ - if (kClockFlexcanSrcOsc0erClk == flexcanSrc) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} -#endif - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - case 3: - case 4: - case 5: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSdhcFreq - * Description : Gets the clock frequency for SDHC module - * This function gets the clock frequency for SDHC module - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance) -{ - uint32_t freq; - clock_sdhc_src_t src; - - src = CLOCK_HAL_GetSdhcSrc(SIM, instance); - - switch (src) - { - case kClockSdhcSrcCoreSysClk: /* Core/system clock */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockSdhcSrcPllFllSel: /* Clock selected by SOPT2[PLLFLLSEL]. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockSdhcSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSdhcSrcExt: /* External bypass clock (SDHC0_CLKIN) */ - freq = g_sdhcClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0, - kSimClockGateDac1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/* FlexCAN instance table. */ -static const sim_clock_gate_name_t flexcanGateTable[] = -{ - kSimClockGateFlexcan0, - kSimClockGateFlexcan1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFlexcanClock - * Description : Enable the clock for Flexcan module - * This function enables the clock for Flexcan module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - SIM_HAL_EnableClock(SIM, flexcanGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFlexcanClock - * Description : Disable the clock for Flexcan module - * This function disables the clock for Flexcan module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - SIM_HAL_DisableClock(SIM, flexcanGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanGateCmd - * Description : Get the the clock gate state for Flexcan module - * This function will get the clock gate state for Flexcan module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, flexcanGateTable[instance]); -} -#endif - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, - kSimClockGateSpi2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, - kSimClockGateUart3, - kSimClockGateUart4, - kSimClockGateUart5 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK52D10/fsl_clock_MK52D10.h b/KSDK_1.2.0/platform/system/src/clock/MK52D10/fsl_clock_MK52D10.h deleted file mode 100644 index d29559c..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK52D10/fsl_clock_MK52D10.h +++ /dev/null @@ -1,2048 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_K52D10_H__) -#define __FSL_CLOCK_K52D10_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k52d10*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief ENET external clock source count. */ -#define ENET_EXT_CLK_COUNT 1 -/*! @brief SDHC external clock source count. */ -#define SDHC_EXT_CLK_COUNT 1 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! @brief ENET external clock frequency(ENET_1588_CLKIN) */ -extern uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; -#endif -/*! @brief SDHC external clock frequency(SDHC_CLKIN). */ -extern uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -#endif -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k52d10_t; -#else -} sim_config_t; -#endif - -/*! @} */ -/*! @addtogroup clock_manager*/ -/*! @{*/ -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider3 setting(OUTDIV3). - * - * This function sets divide value OUTDIV3. - * - * @param outdiv3 Outdivider3 setting - */ -static inline void CLOCK_SYS_SetOutDiv3(uint8_t outdiv3) -{ - CLOCK_HAL_SetOutDiv3(SIM, outdiv3); -} - -/*! - * @brief Gets the clock out divider3 setting(OUTDIV3). - * - * This function gets divide value OUTDIV3. - * - * @return Outdivider3 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv3(void) -{ - return CLOCK_HAL_GetOutDiv3(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Gets ethernet RMII clock source. - * - * This function gets the ethernet RMII clock source. - * - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_rmii_src_t CLOCK_SYS_GetEnetRmiiSrc(uint32_t instance) -{ - return CLOCK_HAL_GetRmiiSrc(SIM, instance); -} - -/*! - * @brief Sets ethernet RMII clock source. - * - * This function sets the ethernet RMII clock source. - * - * @param instance module device instance. - * @param rmiiSrc RMII clock source. - */ -static inline void CLOCK_SYS_SetEnetRmiiSrc(uint32_t instance, clock_rmii_src_t rmiiSrc) -{ - CLOCK_HAL_SetRmiiSrc(SIM, instance, rmiiSrc); -} - -/*! - * @brief Gets ethernet RMII clock frequency. - * - * This function gets the ethernet RMII clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance); -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - /*! - * @brief Gets FLEXCAN clock frequency. - * - * This function gets the FLEXCAN clock frequency. - * - * @param instance module device instance - * @param flexcanSrc clock source - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc); -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param instance module device instance. - * @param timeSrc Ethernet timestamp clock source. - */ -static inline void CLOCK_SYS_SetEnetTimeStampSrc(uint32_t instance, clock_time_src_t timeSrc) -{ - CLOCK_HAL_SetTimeSrc(SIM, instance, timeSrc); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param instance IP instance. - * - * @return Current source. - */ -static inline clock_time_src_t CLOCK_SYS_GetEnetTimeStampSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTimeSrc(SIM, instance); -} - -/*! - * @brief Gets ethernet timestamp clock frequency. - * - * This function gets the ethernet timestamp clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance); -#endif - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} -#endif - -/*! - * @brief Gets the clock frequency for SDHC. - * - * This function gets the clock frequency for SDHC. - * @param instance module device instance - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance); - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetSdhcSrc( uint32_t instance, - clock_sdhc_src_t setting) -{ - CLOCK_HAL_SetSdhcSrc(SIM, instance, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_SYS_GetSdhcSrc(uint32_t instance) -{ - return CLOCK_HAL_GetSdhcSrc(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for USB DCD module - * - * This function gets the clock frequency for USB DCD module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetUsbdcdFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -#if FSL_FEATURE_SOC_OPAMP_COUNT -/*! - * @brief Enable the clock for OPAMP module. - * - * This function enables the clock for OPAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableOpampClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateOpamp); -} - -/*! - * @brief Disable the clock for OPAMP module. - * - * This function disables the clock for OPAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableOpampClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateOpamp); -} - -/*! - * @brief Get the the clock gate state for OPAMP module. - * - * This function will get the clock gate state for OPAMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetOpampGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateOpamp); -} -#endif - -#if FSL_FEATURE_SOC_TRIAMP_COUNT -/*! - * @brief Enable the clock for TRIAMP module. - * - * This function enables the clock for TRIAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTriampClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTriamp); -} - -/*! - * @brief Disable the clock for TRIAMP module. - * - * This function disables the clock for TRIAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTriampClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTriamp); -} - -/*! - * @brief Get the the clock gate state for TRIAMP module. - * - * This function will get the clock gate state for TRIAMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTriampGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTriamp); -} -#endif - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for MPU module. - * - * This function enables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableMpuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Disable the clock for MPU module. - * - * This function disables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableMpuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Get the the clock gate state for MPU module. - * - * This function will get the clock gate state for MPU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetMpuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FLEXBUS module. - * - * This function enables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexbusClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Disable the clock for FLEXBUS module. - * - * This function disables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexbusClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Get the the clock gate state for FLEXBUS module. - * - * This function will get the clock gate state for FLEXBUS module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexbusGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -#if FSL_FEATURE_SOC_RNG_COUNT -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} -#endif - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_LCD_COUNT -/*! - * @brief Enable the clock for SLCD module. - * - * This function enables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSlcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Disable the clock for SLCD module. - * - * This function disables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSlcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Get the the clock gate state for SLCD module. - * - * This function will get the clock gate state for SLCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSlcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Gets the frequency for SLCD default clock. - * - * This function gets the frequency for SLCD default clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdDefaultFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets the frequency for SLCD alternate clock. - * - * This function gets the frequency for SLCD alternate clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAltFreq(uint32_t instance) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} -#endif - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for CMT module. - * - * This function enables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmtClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Disable the clock for CMT module. - * - * This function disables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmtClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Get the the clock gate state for CMT module. - * - * This function will get the clock gate state for CMT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmtGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Enable the clock for ENET module. - * - * This function enables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEnetClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Disable the clock for ENET module. - * - * This function disables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEnetClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Get the the clock gate state for ENET module. - * - * This function will get the clock gate state for ENET module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEnetGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEnet0); -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for USBDCD module. - * - * This function enables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Disable the clock for USBDCD module. - * - * This function disables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Get the the clock gate state for USBDCD module. - * - * This function will get the clock gate state for USBDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbdcd0); -} -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance); - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance); -#endif - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for SDHC module. - * - * This function enables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSdhcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Disable the clock for SDHC module. - * - * This function disables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSdhcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Get the the clock gate state for SDHC module. - * - * This function will get the clock gate state for SDHC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSdhcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Enable the clock for TSI module. - * - * This function enables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTsiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Disable the clock for TSI module. - * - * This function disables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTsiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Get the the clock gate state for TSI module. - * - * This function will get the clock gate state for TSI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTsiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Enable the clock for LLWU module. - * - * This function enables the clock for LLWU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLlwuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLlwu0); -} - -/*! - * @brief Disable the clock for LLWU module. - * - * This function disables the clock for LLWU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLlwuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLlwu0); -} - -/*! - * @brief Get the the clock gate state for LLWU module. - * - * This function will get the clock gate state for LLWU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLlwuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLlwu0); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ENET external clock frequency(ENET_1588_CLKIN). - * - * This function sets the ENET external clock frequency (ENET_1588_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetEnetExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < ENET_EXT_CLK_COUNT); - - g_enet1588ClkInFreq[srcInstance] = freq; -} -#endif - -/*! - * @brief Set the SDHC external clock frequency(SDHC_CLKIN). - * - * This function sets the SDHC external clock frequency (SDHC_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetSdhcExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < SDHC_EXT_CLK_COUNT); - - g_sdhcClkInFreq[srcInstance] = freq; -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} -#endif - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_K52D10_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK53D10/fsl_clock_MK53D10.c b/KSDK_1.2.0/platform/system/src/clock/MK53D10/fsl_clock_MK53D10.c deleted file mode 100755 index 74bc257..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK53D10/fsl_clock_MK53D10.c +++ /dev/null @@ -1,1075 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -#if FSL_FEATURE_SOC_ENET_COUNT -uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; /* ENET_1588_CLKIN */ -#endif -uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; /* SDHC_CLKIN */ -#if FSL_FEATURE_SOC_USB_COUNT -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -#endif -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 1U, 4U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlexBusClock: - *frequency = CLOCK_SYS_GetFlexbusFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexbusFreq - * Description : Gets the clock frequency for FLEXBUS module - * This function gets the clock frequency for FLEXBUS module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexbusFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv3(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG) / 2U; - } - else - { - return CLOCK_SYS_GetCoreClockFreq() / 2U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetRmiiFreq - * Description : Gets the clock frequency for ENET module RMII clock. - * This function gets the clock frequency for ENET module RMII clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance) -{ - /* get the sim clock source setting*/ - if (CLOCK_HAL_GetRmiiSrc(SIM, instance) == kClockRmiiSrcExtalClk) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); /* OSCERCLK */ - } - else - { - return g_enet1588ClkInFreq[0]; /* ENET_1588_CLKIN */ - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetTimeStampFreq - * Description : Gets the clock frequency for ENET module TIME clock. - * This function gets the clock frequency for ENET module TIME clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance) -{ - uint32_t freq; - clock_time_src_t src; - - src = CLOCK_HAL_GetTimeSrc(SIM, instance); - - switch(src) - { - case kClockTimeSrcCoreSysClk: /* Core/System clock. */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockTimeSrcPllFllSel: /* FLL/PLL/IRC48M. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTimeSrcOsc0erClk: /* OSCERCLK. */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTimeSrcExt: /* ENET 1588 clock in. */ - freq = g_enet1588ClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - return freq; -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanFreq - * Description : Gets FLEXCAN clock frequency. - * This function gets the FLEXCAN clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc) -{ - if (kClockFlexcanSrcOsc0erClk == flexcanSrc) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} -#endif - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - case 3: - case 4: - case 5: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSdhcFreq - * Description : Gets the clock frequency for SDHC module - * This function gets the clock frequency for SDHC module - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance) -{ - uint32_t freq; - clock_sdhc_src_t src; - - src = CLOCK_HAL_GetSdhcSrc(SIM, instance); - - switch (src) - { - case kClockSdhcSrcCoreSysClk: /* Core/system clock */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockSdhcSrcPllFllSel: /* Clock selected by SOPT2[PLLFLLSEL]. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockSdhcSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSdhcSrcExt: /* External bypass clock (SDHC0_CLKIN) */ - freq = g_sdhcClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0, - kSimClockGateDac1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/* FlexCAN instance table. */ -static const sim_clock_gate_name_t flexcanGateTable[] = -{ - kSimClockGateFlexcan0, - kSimClockGateFlexcan1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFlexcanClock - * Description : Enable the clock for Flexcan module - * This function enables the clock for Flexcan module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - SIM_HAL_EnableClock(SIM, flexcanGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFlexcanClock - * Description : Disable the clock for Flexcan module - * This function disables the clock for Flexcan module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - SIM_HAL_DisableClock(SIM, flexcanGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanGateCmd - * Description : Get the the clock gate state for Flexcan module - * This function will get the clock gate state for Flexcan module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, flexcanGateTable[instance]); -} -#endif - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, - kSimClockGateSpi2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, - kSimClockGateUart3, - kSimClockGateUart4, - kSimClockGateUart5 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK53D10/fsl_clock_MK53D10.h b/KSDK_1.2.0/platform/system/src/clock/MK53D10/fsl_clock_MK53D10.h deleted file mode 100644 index 9b5421d..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK53D10/fsl_clock_MK53D10.h +++ /dev/null @@ -1,2048 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_K53D10_H__) -#define __FSL_CLOCK_K53D10_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k53d10*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief ENET external clock source count. */ -#define ENET_EXT_CLK_COUNT 1 -/*! @brief SDHC external clock source count. */ -#define SDHC_EXT_CLK_COUNT 1 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! @brief ENET external clock frequency(ENET_1588_CLKIN) */ -extern uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; -#endif -/*! @brief SDHC external clock frequency(SDHC_CLKIN). */ -extern uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -#endif -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k53d10_t; -#else -} sim_config_t; -#endif - -/*! @} */ -/*! @addtogroup clock_manager*/ -/*! @{*/ -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider3 setting(OUTDIV3). - * - * This function sets divide value OUTDIV3. - * - * @param outdiv3 Outdivider3 setting - */ -static inline void CLOCK_SYS_SetOutDiv3(uint8_t outdiv3) -{ - CLOCK_HAL_SetOutDiv3(SIM, outdiv3); -} - -/*! - * @brief Gets the clock out divider3 setting(OUTDIV3). - * - * This function gets divide value OUTDIV3. - * - * @return Outdivider3 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv3(void) -{ - return CLOCK_HAL_GetOutDiv3(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Gets ethernet RMII clock source. - * - * This function gets the ethernet RMII clock source. - * - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_rmii_src_t CLOCK_SYS_GetEnetRmiiSrc(uint32_t instance) -{ - return CLOCK_HAL_GetRmiiSrc(SIM, instance); -} - -/*! - * @brief Sets ethernet RMII clock source. - * - * This function sets the ethernet RMII clock source. - * - * @param instance module device instance. - * @param rmiiSrc RMII clock source. - */ -static inline void CLOCK_SYS_SetEnetRmiiSrc(uint32_t instance, clock_rmii_src_t rmiiSrc) -{ - CLOCK_HAL_SetRmiiSrc(SIM, instance, rmiiSrc); -} - -/*! - * @brief Gets ethernet RMII clock frequency. - * - * This function gets the ethernet RMII clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance); -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - /*! - * @brief Gets FLEXCAN clock frequency. - * - * This function gets the FLEXCAN clock frequency. - * - * @param instance module device instance - * @param flexcanSrc clock source - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc); -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param instance module device instance. - * @param timeSrc Ethernet timestamp clock source. - */ -static inline void CLOCK_SYS_SetEnetTimeStampSrc(uint32_t instance, clock_time_src_t timeSrc) -{ - CLOCK_HAL_SetTimeSrc(SIM, instance, timeSrc); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param instance IP instance. - * - * @return Current source. - */ -static inline clock_time_src_t CLOCK_SYS_GetEnetTimeStampSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTimeSrc(SIM, instance); -} - -/*! - * @brief Gets ethernet timestamp clock frequency. - * - * This function gets the ethernet timestamp clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance); -#endif - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} -#endif - -/*! - * @brief Gets the clock frequency for SDHC. - * - * This function gets the clock frequency for SDHC. - * @param instance module device instance - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance); - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetSdhcSrc( uint32_t instance, - clock_sdhc_src_t setting) -{ - CLOCK_HAL_SetSdhcSrc(SIM, instance, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_SYS_GetSdhcSrc(uint32_t instance) -{ - return CLOCK_HAL_GetSdhcSrc(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for USB DCD module - * - * This function gets the clock frequency for USB DCD module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetUsbdcdFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -#if FSL_FEATURE_SOC_OPAMP_COUNT -/*! - * @brief Enable the clock for OPAMP module. - * - * This function enables the clock for OPAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableOpampClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateOpamp); -} - -/*! - * @brief Disable the clock for OPAMP module. - * - * This function disables the clock for OPAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableOpampClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateOpamp); -} - -/*! - * @brief Get the the clock gate state for OPAMP module. - * - * This function will get the clock gate state for OPAMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetOpampGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateOpamp); -} -#endif - -#if FSL_FEATURE_SOC_TRIAMP_COUNT -/*! - * @brief Enable the clock for TRIAMP module. - * - * This function enables the clock for TRIAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTriampClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTriamp); -} - -/*! - * @brief Disable the clock for TRIAMP module. - * - * This function disables the clock for TRIAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTriampClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTriamp); -} - -/*! - * @brief Get the the clock gate state for TRIAMP module. - * - * This function will get the clock gate state for TRIAMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTriampGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTriamp); -} -#endif - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for MPU module. - * - * This function enables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableMpuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Disable the clock for MPU module. - * - * This function disables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableMpuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Get the the clock gate state for MPU module. - * - * This function will get the clock gate state for MPU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetMpuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FLEXBUS module. - * - * This function enables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexbusClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Disable the clock for FLEXBUS module. - * - * This function disables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexbusClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Get the the clock gate state for FLEXBUS module. - * - * This function will get the clock gate state for FLEXBUS module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexbusGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -#if FSL_FEATURE_SOC_RNG_COUNT -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} -#endif - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_LCD_COUNT -/*! - * @brief Enable the clock for SLCD module. - * - * This function enables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSlcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Disable the clock for SLCD module. - * - * This function disables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSlcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Get the the clock gate state for SLCD module. - * - * This function will get the clock gate state for SLCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSlcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Gets the frequency for SLCD default clock. - * - * This function gets the frequency for SLCD default clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdDefaultFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets the frequency for SLCD alternate clock. - * - * This function gets the frequency for SLCD alternate clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAltFreq(uint32_t instance) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} -#endif - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for CMT module. - * - * This function enables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmtClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Disable the clock for CMT module. - * - * This function disables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmtClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Get the the clock gate state for CMT module. - * - * This function will get the clock gate state for CMT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmtGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Enable the clock for ENET module. - * - * This function enables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEnetClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Disable the clock for ENET module. - * - * This function disables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEnetClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Get the the clock gate state for ENET module. - * - * This function will get the clock gate state for ENET module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEnetGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEnet0); -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for USBDCD module. - * - * This function enables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Disable the clock for USBDCD module. - * - * This function disables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Get the the clock gate state for USBDCD module. - * - * This function will get the clock gate state for USBDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbdcd0); -} -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance); - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance); -#endif - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for SDHC module. - * - * This function enables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSdhcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Disable the clock for SDHC module. - * - * This function disables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSdhcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Get the the clock gate state for SDHC module. - * - * This function will get the clock gate state for SDHC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSdhcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Enable the clock for TSI module. - * - * This function enables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTsiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Disable the clock for TSI module. - * - * This function disables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTsiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Get the the clock gate state for TSI module. - * - * This function will get the clock gate state for TSI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTsiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Enable the clock for LLWU module. - * - * This function enables the clock for LLWU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLlwuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLlwu0); -} - -/*! - * @brief Disable the clock for LLWU module. - * - * This function disables the clock for LLWU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLlwuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLlwu0); -} - -/*! - * @brief Get the the clock gate state for LLWU module. - * - * This function will get the clock gate state for LLWU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLlwuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLlwu0); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ENET external clock frequency(ENET_1588_CLKIN). - * - * This function sets the ENET external clock frequency (ENET_1588_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetEnetExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < ENET_EXT_CLK_COUNT); - - g_enet1588ClkInFreq[srcInstance] = freq; -} -#endif - -/*! - * @brief Set the SDHC external clock frequency(SDHC_CLKIN). - * - * This function sets the SDHC external clock frequency (SDHC_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetSdhcExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < SDHC_EXT_CLK_COUNT); - - g_sdhcClkInFreq[srcInstance] = freq; -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} -#endif - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_K53D10_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK60D10/fsl_clock_MK60D10.c b/KSDK_1.2.0/platform/system/src/clock/MK60D10/fsl_clock_MK60D10.c deleted file mode 100755 index 74bc257..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK60D10/fsl_clock_MK60D10.c +++ /dev/null @@ -1,1075 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -#if FSL_FEATURE_SOC_ENET_COUNT -uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; /* ENET_1588_CLKIN */ -#endif -uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; /* SDHC_CLKIN */ -#if FSL_FEATURE_SOC_USB_COUNT -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -#endif -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 1U, 4U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlexBusClock: - *frequency = CLOCK_SYS_GetFlexbusFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexbusFreq - * Description : Gets the clock frequency for FLEXBUS module - * This function gets the clock frequency for FLEXBUS module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexbusFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv3(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG) / 2U; - } - else - { - return CLOCK_SYS_GetCoreClockFreq() / 2U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetRmiiFreq - * Description : Gets the clock frequency for ENET module RMII clock. - * This function gets the clock frequency for ENET module RMII clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance) -{ - /* get the sim clock source setting*/ - if (CLOCK_HAL_GetRmiiSrc(SIM, instance) == kClockRmiiSrcExtalClk) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); /* OSCERCLK */ - } - else - { - return g_enet1588ClkInFreq[0]; /* ENET_1588_CLKIN */ - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetTimeStampFreq - * Description : Gets the clock frequency for ENET module TIME clock. - * This function gets the clock frequency for ENET module TIME clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance) -{ - uint32_t freq; - clock_time_src_t src; - - src = CLOCK_HAL_GetTimeSrc(SIM, instance); - - switch(src) - { - case kClockTimeSrcCoreSysClk: /* Core/System clock. */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockTimeSrcPllFllSel: /* FLL/PLL/IRC48M. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTimeSrcOsc0erClk: /* OSCERCLK. */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTimeSrcExt: /* ENET 1588 clock in. */ - freq = g_enet1588ClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - return freq; -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanFreq - * Description : Gets FLEXCAN clock frequency. - * This function gets the FLEXCAN clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc) -{ - if (kClockFlexcanSrcOsc0erClk == flexcanSrc) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} -#endif - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - case 3: - case 4: - case 5: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSdhcFreq - * Description : Gets the clock frequency for SDHC module - * This function gets the clock frequency for SDHC module - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance) -{ - uint32_t freq; - clock_sdhc_src_t src; - - src = CLOCK_HAL_GetSdhcSrc(SIM, instance); - - switch (src) - { - case kClockSdhcSrcCoreSysClk: /* Core/system clock */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockSdhcSrcPllFllSel: /* Clock selected by SOPT2[PLLFLLSEL]. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockSdhcSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSdhcSrcExt: /* External bypass clock (SDHC0_CLKIN) */ - freq = g_sdhcClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0, - kSimClockGateDac1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/* FlexCAN instance table. */ -static const sim_clock_gate_name_t flexcanGateTable[] = -{ - kSimClockGateFlexcan0, - kSimClockGateFlexcan1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFlexcanClock - * Description : Enable the clock for Flexcan module - * This function enables the clock for Flexcan module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - SIM_HAL_EnableClock(SIM, flexcanGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFlexcanClock - * Description : Disable the clock for Flexcan module - * This function disables the clock for Flexcan module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - SIM_HAL_DisableClock(SIM, flexcanGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanGateCmd - * Description : Get the the clock gate state for Flexcan module - * This function will get the clock gate state for Flexcan module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance) -{ - assert(instance < sizeof(flexcanGateTable)/sizeof(flexcanGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, flexcanGateTable[instance]); -} -#endif - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, - kSimClockGateSpi2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, - kSimClockGateUart3, - kSimClockGateUart4, - kSimClockGateUart5 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK60D10/fsl_clock_MK60D10.h b/KSDK_1.2.0/platform/system/src/clock/MK60D10/fsl_clock_MK60D10.h deleted file mode 100644 index b8da475..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK60D10/fsl_clock_MK60D10.h +++ /dev/null @@ -1,2048 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_K60D10_H__) -#define __FSL_CLOCK_K60D10_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k60d10*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief ENET external clock source count. */ -#define ENET_EXT_CLK_COUNT 1 -/*! @brief SDHC external clock source count. */ -#define SDHC_EXT_CLK_COUNT 1 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! @brief ENET external clock frequency(ENET_1588_CLKIN) */ -extern uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; -#endif -/*! @brief SDHC external clock frequency(SDHC_CLKIN). */ -extern uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -#endif -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k60d10_t; -#else -} sim_config_t; -#endif - -/*! @} */ -/*! @addtogroup clock_manager*/ -/*! @{*/ -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider3 setting(OUTDIV3). - * - * This function sets divide value OUTDIV3. - * - * @param outdiv3 Outdivider3 setting - */ -static inline void CLOCK_SYS_SetOutDiv3(uint8_t outdiv3) -{ - CLOCK_HAL_SetOutDiv3(SIM, outdiv3); -} - -/*! - * @brief Gets the clock out divider3 setting(OUTDIV3). - * - * This function gets divide value OUTDIV3. - * - * @return Outdivider3 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv3(void) -{ - return CLOCK_HAL_GetOutDiv3(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Gets ethernet RMII clock source. - * - * This function gets the ethernet RMII clock source. - * - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_rmii_src_t CLOCK_SYS_GetEnetRmiiSrc(uint32_t instance) -{ - return CLOCK_HAL_GetRmiiSrc(SIM, instance); -} - -/*! - * @brief Sets ethernet RMII clock source. - * - * This function sets the ethernet RMII clock source. - * - * @param instance module device instance. - * @param rmiiSrc RMII clock source. - */ -static inline void CLOCK_SYS_SetEnetRmiiSrc(uint32_t instance, clock_rmii_src_t rmiiSrc) -{ - CLOCK_HAL_SetRmiiSrc(SIM, instance, rmiiSrc); -} - -/*! - * @brief Gets ethernet RMII clock frequency. - * - * This function gets the ethernet RMII clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance); -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT - /*! - * @brief Gets FLEXCAN clock frequency. - * - * This function gets the FLEXCAN clock frequency. - * - * @param instance module device instance - * @param flexcanSrc clock source - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc); -#endif - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param instance module device instance. - * @param timeSrc Ethernet timestamp clock source. - */ -static inline void CLOCK_SYS_SetEnetTimeStampSrc(uint32_t instance, clock_time_src_t timeSrc) -{ - CLOCK_HAL_SetTimeSrc(SIM, instance, timeSrc); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param instance IP instance. - * - * @return Current source. - */ -static inline clock_time_src_t CLOCK_SYS_GetEnetTimeStampSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTimeSrc(SIM, instance); -} - -/*! - * @brief Gets ethernet timestamp clock frequency. - * - * This function gets the ethernet timestamp clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance); -#endif - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} -#endif - -/*! - * @brief Gets the clock frequency for SDHC. - * - * This function gets the clock frequency for SDHC. - * @param instance module device instance - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance); - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetSdhcSrc( uint32_t instance, - clock_sdhc_src_t setting) -{ - CLOCK_HAL_SetSdhcSrc(SIM, instance, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_SYS_GetSdhcSrc(uint32_t instance) -{ - return CLOCK_HAL_GetSdhcSrc(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for USB DCD module - * - * This function gets the clock frequency for USB DCD module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetUsbdcdFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -#if FSL_FEATURE_SOC_OPAMP_COUNT -/*! - * @brief Enable the clock for OPAMP module. - * - * This function enables the clock for OPAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableOpampClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateOpamp); -} - -/*! - * @brief Disable the clock for OPAMP module. - * - * This function disables the clock for OPAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableOpampClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateOpamp); -} - -/*! - * @brief Get the the clock gate state for OPAMP module. - * - * This function will get the clock gate state for OPAMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetOpampGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateOpamp); -} -#endif - -#if FSL_FEATURE_SOC_TRIAMP_COUNT -/*! - * @brief Enable the clock for TRIAMP module. - * - * This function enables the clock for TRIAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTriampClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTriamp); -} - -/*! - * @brief Disable the clock for TRIAMP module. - * - * This function disables the clock for TRIAMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTriampClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTriamp); -} - -/*! - * @brief Get the the clock gate state for TRIAMP module. - * - * This function will get the clock gate state for TRIAMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTriampGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTriamp); -} -#endif - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for MPU module. - * - * This function enables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableMpuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Disable the clock for MPU module. - * - * This function disables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableMpuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Get the the clock gate state for MPU module. - * - * This function will get the clock gate state for MPU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetMpuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FLEXBUS module. - * - * This function enables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexbusClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Disable the clock for FLEXBUS module. - * - * This function disables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexbusClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Get the the clock gate state for FLEXBUS module. - * - * This function will get the clock gate state for FLEXBUS module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexbusGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -#if FSL_FEATURE_SOC_RNG_COUNT -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} -#endif - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_LCD_COUNT -/*! - * @brief Enable the clock for SLCD module. - * - * This function enables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSlcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Disable the clock for SLCD module. - * - * This function disables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSlcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Get the the clock gate state for SLCD module. - * - * This function will get the clock gate state for SLCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSlcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Gets the frequency for SLCD default clock. - * - * This function gets the frequency for SLCD default clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdDefaultFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets the frequency for SLCD alternate clock. - * - * This function gets the frequency for SLCD alternate clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAltFreq(uint32_t instance) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} -#endif - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for CMT module. - * - * This function enables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmtClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Disable the clock for CMT module. - * - * This function disables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmtClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Get the the clock gate state for CMT module. - * - * This function will get the clock gate state for CMT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmtGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Enable the clock for ENET module. - * - * This function enables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEnetClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Disable the clock for ENET module. - * - * This function disables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEnetClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Get the the clock gate state for ENET module. - * - * This function will get the clock gate state for ENET module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEnetGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEnet0); -} -#endif - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for USBDCD module. - * - * This function enables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Disable the clock for USBDCD module. - * - * This function disables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Get the the clock gate state for USBDCD module. - * - * This function will get the clock gate state for USBDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbdcd0); -} -#endif - -#if FSL_FEATURE_SOC_FLEXCAN_COUNT -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance); - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance); -#endif - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for SDHC module. - * - * This function enables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSdhcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Disable the clock for SDHC module. - * - * This function disables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSdhcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Get the the clock gate state for SDHC module. - * - * This function will get the clock gate state for SDHC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSdhcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Enable the clock for TSI module. - * - * This function enables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTsiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Disable the clock for TSI module. - * - * This function disables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTsiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Get the the clock gate state for TSI module. - * - * This function will get the clock gate state for TSI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTsiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Enable the clock for LLWU module. - * - * This function enables the clock for LLWU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLlwuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLlwu0); -} - -/*! - * @brief Disable the clock for LLWU module. - * - * This function disables the clock for LLWU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLlwuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLlwu0); -} - -/*! - * @brief Get the the clock gate state for LLWU module. - * - * This function will get the clock gate state for LLWU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLlwuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLlwu0); -} - -#if FSL_FEATURE_SOC_ENET_COUNT -/*! - * @brief Set the ENET external clock frequency(ENET_1588_CLKIN). - * - * This function sets the ENET external clock frequency (ENET_1588_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetEnetExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < ENET_EXT_CLK_COUNT); - - g_enet1588ClkInFreq[srcInstance] = freq; -} -#endif - -/*! - * @brief Set the SDHC external clock frequency(SDHC_CLKIN). - * - * This function sets the SDHC external clock frequency (SDHC_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetSdhcExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < SDHC_EXT_CLK_COUNT); - - g_sdhcClkInFreq[srcInstance] = freq; -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} -#endif - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequency value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_K60D10_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK63F12/fsl_clock_MK63F12.c b/KSDK_1.2.0/platform/system/src/clock/MK63F12/fsl_clock_MK63F12.c deleted file mode 100755 index 0bd613c..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK63F12/fsl_clock_MK63F12.c +++ /dev/null @@ -1,1026 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; /* ENET_1588_CLKIN */ -uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; /* SDHC_CLKIN */ -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 2U, 4U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlexBusClock: - *frequency = CLOCK_SYS_GetFlexbusFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kIrc48mClock: - *frequency = CPU_INTERNAL_IRC_48M; - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the systen clock frequency. - * This function gets the systen clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexbusFreq - * Description : Gets the clock frequency for FLEXBUS module - * This function gets the clock frequency for FLEXBUS moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexbusFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv3(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockPllFllSelIrc48M: - freq = CPU_INTERNAL_IRC_48M; - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG) / 2U; - } - else - { - return CLOCK_SYS_GetCoreClockFreq() / 2U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx prescaler/glitch filter clock frequency. - * This function gets the LPTMRx prescaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetRmiiFreq - * Description : Gets the clock frequency for ENET module RMII clock. - * This function gets the clock frequency for ENET moudle RMII clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance) -{ - /* get the sim clock source setting*/ - if (CLOCK_HAL_GetRmiiSrc(SIM, instance) == kClockRmiiSrcExtalClk) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); /* OSCERCLK */ - } - else - { - return g_enet1588ClkInFreq[0]; /* ENET_1588_CLKIN */ - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetTimeStampFreq - * Description : Gets the clock frequency for ENET module TIME clock. - * This function gets the clock frequency for ENET moudle TIME clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance) -{ - uint32_t freq; - clock_time_src_t src; - - src = CLOCK_HAL_GetTimeSrc(SIM, instance); - - switch(src) - { - case kClockTimeSrcCoreSysClk: /* Core/System clock. */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockTimeSrcPllFllSel: /* FLL/PLL/IRC48M. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTimeSrcOsc0erClk: /* OSCERCLK. */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTimeSrcExt: /* ENET 1588 clock in. */ - freq = g_enet1588ClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanFreq - * Description : Gets FLEXCAN clock frequency. - * This function gets the FLEXCAN clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc) -{ - if (kClockFlexcanSrcOsc0erClk == flexcanSrc) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - case 3: - case 4: - case 5: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSdhcFreq - * Description : Gets the clock frequency for SDHC module - * This function gets the clock frequency for SDHC moudle - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance) -{ - uint32_t freq; - clock_sdhc_src_t src; - - src = CLOCK_HAL_GetSdhcSrc(SIM, instance); - - switch (src) - { - case kClockSdhcSrcCoreSysClk: /* Core/system clock */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockSdhcSrcPllFllSel: /* Clock selected by SOPT2[PLLFLLSEL]. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockSdhcSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSdhcSrcExt: /* External bypass clock (SDHC0_CLKIN) */ - freq = g_sdhcClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0, - kSimClockGateDac1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, - kSimClockGateFtm3 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, - kSimClockGateSpi2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1, - kSimClockGateI2c2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, - kSimClockGateUart3, - kSimClockGateUart4, - kSimClockGateUart5 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK63F12/fsl_clock_MK63F12.h b/KSDK_1.2.0/platform/system/src/clock/MK63F12/fsl_clock_MK63F12.h deleted file mode 100644 index 8a546ad..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK63F12/fsl_clock_MK63F12.h +++ /dev/null @@ -1,1834 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_MK63F12_H__) -#define __FSL_CLOCK_MK63F12_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k63f12 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/*! @brief ENET external clock source count. */ -#define ENET_EXT_CLK_COUNT 1 -/*! @brief SDHC external clock source count. */ -#define SDHC_EXT_CLK_COUNT 1 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -/*! @brief ENET external clock frequency(ENET_1588_CLKIN) */ -extern uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; -/*! @brief SDHC external clock frequency(SDHC_CLKIN). */ -extern uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k63f12_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider3 setting(OUTDIV3). - * - * This function sets divide value OUTDIV3. - * - * @param outdiv3 Outdivider3 setting - */ -static inline void CLOCK_SYS_SetOutDiv3(uint8_t outdiv3) -{ - CLOCK_HAL_SetOutDiv3(SIM, outdiv3); -} - -/*! - * @brief Gets the clock out divider3 setting(OUTDIV3). - * - * This function gets divide value OUTDIV3. - * - * @return Outdivider3 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv3(void) -{ - return CLOCK_HAL_GetOutDiv3(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets ethernet RMII clock source. - * - * This function gets the ethernet RMII clock source. - * - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_rmii_src_t CLOCK_SYS_GetEnetRmiiSrc(uint32_t instance) -{ - return CLOCK_HAL_GetRmiiSrc(SIM, instance); -} - -/*! - * @brief Sets ethernet RMII clock source. - * - * This function sets the ethernet RMII clock source. - * - * @param instance module device instance. - * @param rmiiSrc RMII clock source. - */ -static inline void CLOCK_SYS_SetEnetRmiiSrc(uint32_t instance, clock_rmii_src_t rmiiSrc) -{ - CLOCK_HAL_SetRmiiSrc(SIM, instance, rmiiSrc); -} - -/*! - * @brief Gets ethernet RMII clock frequency. - * - * This function gets the ethernet RMII clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance); - -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param instance module device instance. - * @param timeSrc Ethernet timestamp clock source. - */ -static inline void CLOCK_SYS_SetEnetTimeStampSrc(uint32_t instance, clock_time_src_t timeSrc) -{ - CLOCK_HAL_SetTimeSrc(SIM, instance, timeSrc); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param instance IP instance. - * - * @return Current source. - */ -static inline clock_time_src_t CLOCK_SYS_GetEnetTimeStampSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTimeSrc(SIM, instance); -} - -/*! - * @brief Gets ethernet timestamp clock frequency. - * - * This function gets the ethernet timestamp clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS moduel instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} - - /*! - * @brief Gets FLEXCAN clock frequency. - * - * This function gets the FLEXCAN clock frequency. - * - * @param instance module device instance - * @param flexcanSrc clock source - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc); - -/*! - * @brief Gets the clock frequency for SDHC. - * - * This function gets the clock frequency for SDHC. - * @param instance module device instance - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance); - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetSdhcSrc( uint32_t instance, - clock_sdhc_src_t setting) -{ - CLOCK_HAL_SetSdhcSrc(SIM, instance, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_SYS_GetSdhcSrc(uint32_t instance) -{ - return CLOCK_HAL_GetSdhcSrc(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for USB DCD module - * - * This function gets the clock frequency for USB DCD module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetUsbdcdFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for MPU module. - * - * This function enables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableMpuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Disable the clock for MPU module. - * - * This function disables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableMpuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Get the the clock gate state for MPU module. - * - * This function will get the clock gate state for MPU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetMpuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FLEXBUS module. - * - * This function enables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexbusClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Disable the clock for FLEXBUS module. - * - * This function disables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexbusClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Get the the clock gate state for FLEXBUS module. - * - * This function will get the clock gate state for FLEXBUS module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexbusGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for CMT module. - * - * This function enables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmtClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Disable the clock for CMT module. - * - * This function disables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmtClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Get the the clock gate state for CMT module. - * - * This function will get the clock gate state for CMT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmtGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Enable the clock for ENET module. - * - * This function enables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEnetClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Disable the clock for ENET module. - * - * This function disables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEnetClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Get the the clock gate state for ENET module. - * - * This function will get the clock gate state for ENET module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEnetGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for USBDCD module. - * - * This function enables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Disable the clock for USBDCD module. - * - * This function disables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Get the the clock gate state for USBDCD module. - * - * This function will get the clock gate state for USBDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexcanClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexcan0); -} - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexcanClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexcan0); -} - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFlexcan0); -} - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for SDHC module. - * - * This function enables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSdhcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Disable the clock for SDHC module. - * - * This function disables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSdhcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Get the the clock gate state for SDHC module. - * - * This function will get the clock gate state for SDHC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSdhcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Set the ENET external clock frequency(ENET_1588_CLKIN). - * - * This function sets the ENET external clock frequency (ENET_1588_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetEnetExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < ENET_EXT_CLK_COUNT); - - g_enet1588ClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the SDHC external clock frequency(SDHC_CLKIN). - * - * This function sets the SDHC external clock frequency (SDHC_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetSdhcExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < SDHC_EXT_CLK_COUNT); - - g_sdhcClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_MK63F12_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK64F12/fsl_clock_MK64F12.c b/KSDK_1.2.0/platform/system/src/clock/MK64F12/fsl_clock_MK64F12.c deleted file mode 100755 index 0bd613c..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK64F12/fsl_clock_MK64F12.c +++ /dev/null @@ -1,1026 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; /* ENET_1588_CLKIN */ -uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; /* SDHC_CLKIN */ -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 2U, 4U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlexBusClock: - *frequency = CLOCK_SYS_GetFlexbusFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kIrc48mClock: - *frequency = CPU_INTERNAL_IRC_48M; - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the systen clock frequency. - * This function gets the systen clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexbusFreq - * Description : Gets the clock frequency for FLEXBUS module - * This function gets the clock frequency for FLEXBUS moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexbusFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv3(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockPllFllSelIrc48M: - freq = CPU_INTERNAL_IRC_48M; - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG) / 2U; - } - else - { - return CLOCK_SYS_GetCoreClockFreq() / 2U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx prescaler/glitch filter clock frequency. - * This function gets the LPTMRx prescaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetRmiiFreq - * Description : Gets the clock frequency for ENET module RMII clock. - * This function gets the clock frequency for ENET moudle RMII clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance) -{ - /* get the sim clock source setting*/ - if (CLOCK_HAL_GetRmiiSrc(SIM, instance) == kClockRmiiSrcExtalClk) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); /* OSCERCLK */ - } - else - { - return g_enet1588ClkInFreq[0]; /* ENET_1588_CLKIN */ - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetTimeStampFreq - * Description : Gets the clock frequency for ENET module TIME clock. - * This function gets the clock frequency for ENET moudle TIME clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance) -{ - uint32_t freq; - clock_time_src_t src; - - src = CLOCK_HAL_GetTimeSrc(SIM, instance); - - switch(src) - { - case kClockTimeSrcCoreSysClk: /* Core/System clock. */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockTimeSrcPllFllSel: /* FLL/PLL/IRC48M. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTimeSrcOsc0erClk: /* OSCERCLK. */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTimeSrcExt: /* ENET 1588 clock in. */ - freq = g_enet1588ClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanFreq - * Description : Gets FLEXCAN clock frequency. - * This function gets the FLEXCAN clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc) -{ - if (kClockFlexcanSrcOsc0erClk == flexcanSrc) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - case 3: - case 4: - case 5: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSdhcFreq - * Description : Gets the clock frequency for SDHC module - * This function gets the clock frequency for SDHC moudle - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance) -{ - uint32_t freq; - clock_sdhc_src_t src; - - src = CLOCK_HAL_GetSdhcSrc(SIM, instance); - - switch (src) - { - case kClockSdhcSrcCoreSysClk: /* Core/system clock */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockSdhcSrcPllFllSel: /* Clock selected by SOPT2[PLLFLLSEL]. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockSdhcSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSdhcSrcExt: /* External bypass clock (SDHC0_CLKIN) */ - freq = g_sdhcClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0, - kSimClockGateDac1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, - kSimClockGateFtm3 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, - kSimClockGateSpi2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1, - kSimClockGateI2c2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, - kSimClockGateUart3, - kSimClockGateUart4, - kSimClockGateUart5 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK64F12/fsl_clock_MK64F12.h b/KSDK_1.2.0/platform/system/src/clock/MK64F12/fsl_clock_MK64F12.h deleted file mode 100644 index f678feb..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK64F12/fsl_clock_MK64F12.h +++ /dev/null @@ -1,1834 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_K64F12_H__) -#define __FSL_CLOCK_K64F12_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k64f12 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/*! @brief ENET external clock source count. */ -#define ENET_EXT_CLK_COUNT 1 -/*! @brief SDHC external clock source count. */ -#define SDHC_EXT_CLK_COUNT 1 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -/*! @brief ENET external clock frequency(ENET_1588_CLKIN) */ -extern uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; -/*! @brief SDHC external clock frequency(SDHC_CLKIN). */ -extern uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k64f12_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider3 setting(OUTDIV3). - * - * This function sets divide value OUTDIV3. - * - * @param outdiv3 Outdivider3 setting - */ -static inline void CLOCK_SYS_SetOutDiv3(uint8_t outdiv3) -{ - CLOCK_HAL_SetOutDiv3(SIM, outdiv3); -} - -/*! - * @brief Gets the clock out divider3 setting(OUTDIV3). - * - * This function gets divide value OUTDIV3. - * - * @return Outdivider3 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv3(void) -{ - return CLOCK_HAL_GetOutDiv3(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets ethernet RMII clock source. - * - * This function gets the ethernet RMII clock source. - * - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_rmii_src_t CLOCK_SYS_GetEnetRmiiSrc(uint32_t instance) -{ - return CLOCK_HAL_GetRmiiSrc(SIM, instance); -} - -/*! - * @brief Sets ethernet RMII clock source. - * - * This function sets the ethernet RMII clock source. - * - * @param instance module device instance. - * @param rmiiSrc RMII clock source. - */ -static inline void CLOCK_SYS_SetEnetRmiiSrc(uint32_t instance, clock_rmii_src_t rmiiSrc) -{ - CLOCK_HAL_SetRmiiSrc(SIM, instance, rmiiSrc); -} - -/*! - * @brief Gets ethernet RMII clock frequency. - * - * This function gets the ethernet RMII clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance); - -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param instance module device instance. - * @param timeSrc Ethernet timestamp clock source. - */ -static inline void CLOCK_SYS_SetEnetTimeStampSrc(uint32_t instance, clock_time_src_t timeSrc) -{ - CLOCK_HAL_SetTimeSrc(SIM, instance, timeSrc); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param instance IP instance. - * - * @return Current source. - */ -static inline clock_time_src_t CLOCK_SYS_GetEnetTimeStampSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTimeSrc(SIM, instance); -} - -/*! - * @brief Gets ethernet timestamp clock frequency. - * - * This function gets the ethernet timestamp clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS moduel instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} - - /*! - * @brief Gets FLEXCAN clock frequency. - * - * This function gets the FLEXCAN clock frequency. - * - * @param instance module device instance - * @param flexcanSrc clock source - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc); - -/*! - * @brief Gets the clock frequency for SDHC. - * - * This function gets the clock frequency for SDHC. - * @param instance module device instance - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance); - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetSdhcSrc( uint32_t instance, - clock_sdhc_src_t setting) -{ - CLOCK_HAL_SetSdhcSrc(SIM, instance, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_SYS_GetSdhcSrc(uint32_t instance) -{ - return CLOCK_HAL_GetSdhcSrc(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for USB DCD module - * - * This function gets the clock frequency for USB DCD module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetUsbdcdFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for MPU module. - * - * This function enables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableMpuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Disable the clock for MPU module. - * - * This function disables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableMpuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Get the the clock gate state for MPU module. - * - * This function will get the clock gate state for MPU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetMpuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FLEXBUS module. - * - * This function enables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexbusClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Disable the clock for FLEXBUS module. - * - * This function disables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexbusClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Get the the clock gate state for FLEXBUS module. - * - * This function will get the clock gate state for FLEXBUS module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexbusGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for CMT module. - * - * This function enables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmtClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Disable the clock for CMT module. - * - * This function disables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmtClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Get the the clock gate state for CMT module. - * - * This function will get the clock gate state for CMT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmtGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Enable the clock for ENET module. - * - * This function enables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEnetClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Disable the clock for ENET module. - * - * This function disables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEnetClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Get the the clock gate state for ENET module. - * - * This function will get the clock gate state for ENET module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEnetGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for USBDCD module. - * - * This function enables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Disable the clock for USBDCD module. - * - * This function disables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Get the the clock gate state for USBDCD module. - * - * This function will get the clock gate state for USBDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexcanClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexcan0); -} - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexcanClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexcan0); -} - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFlexcan0); -} - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for SDHC module. - * - * This function enables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSdhcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Disable the clock for SDHC module. - * - * This function disables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSdhcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Get the the clock gate state for SDHC module. - * - * This function will get the clock gate state for SDHC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSdhcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Set the ENET external clock frequency(ENET_1588_CLKIN). - * - * This function sets the ENET external clock frequency (ENET_1588_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetEnetExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < ENET_EXT_CLK_COUNT); - - g_enet1588ClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the SDHC external clock frequency(SDHC_CLKIN). - * - * This function sets the SDHC external clock frequency (SDHC_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetSdhcExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < SDHC_EXT_CLK_COUNT); - - g_sdhcClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_K64F12_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK65F18/fsl_clock_MK65F18.c b/KSDK_1.2.0/platform/system/src/clock/MK65F18/fsl_clock_MK65F18.c deleted file mode 100755 index 26a52a0..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK65F18/fsl_clock_MK65F18.c +++ /dev/null @@ -1,1275 +0,0 @@ -/* - * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; /* ENET_1588_CLKIN */ -uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; /* SDHC_CLKIN */ -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ -uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; /* TPM_CLK */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - CLOCK_HAL_SetPllFllDiv(SIM, simConfig->pllflldiv, simConfig->pllfllfrac); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 3U, 7U, 7U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlexBusClock: - *frequency = CLOCK_SYS_GetFlexbusFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kOsc0ErClockUndiv: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgExtPllClock: - *frequency = CLOCK_HAL_GetExtPllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kIrc48mClock: - *frequency = CPU_INTERNAL_IRC_48M; - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexbusFreq - * Description : Gets the clock frequency for FLEXBUS module - * This function gets the clock frequency for FLEXBUS module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexbusFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv3(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockPllFllSelUsb1pfd: - freq = CLOCK_HAL_GetExtPllClk(MCG); - break; - case kClockPllFllSelIrc48M: - freq = CPU_INTERNAL_IRC_48M; - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllDivClockFreq - * Description : Gets the PLL/FLL clock divided by the fractional divider. - * This function gets the frequency of the PLL/FLL clock divided - * by the fractional divider configured by SIM_CLKDIV3[PLLFLLFRAC, PLLFLLDIV]. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllDivClockFreq(void) -{ - uint32_t freq; - uint8_t pllflldiv, pllfllfrac; - - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetPllFllDiv(SIM, &pllflldiv, &pllfllfrac); - return freq * (pllfllfrac + 1) / (pllflldiv + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq - * Description : Gets OSC0ERCLKUDIV. - * This function gets the OSC0 external reference undivided frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq() - >> OSC_HAL_GetExternalRefClkDiv(g_oscBase[0]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - uint32_t freq; - uint8_t tracediv, tracefrac; - - if (kClockTraceSrcMcgoutClkDiv == src) - { - freq = CLOCK_HAL_GetOutClk(MCG); - CLOCK_HAL_GetTraceDiv(SIM, &tracediv, &tracefrac); - return freq * (tracefrac + 1) / (tracediv + 1); - } - else - { - freq = CLOCK_SYS_GetCoreClockFreq(); - } - return freq / 2U; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClkUndiv: /* OSC0ERCLKUDIV clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmfFreq - * Description : Gets the clock frequency for TPM module. - * This function gets the clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance) -{ - uint32_t freq; - clock_tpm_src_t src; - - src = CLOCK_HAL_GetTpmSrc(SIM, instance); - - switch(src) - { - case kClockTpmSrcPllFllSelDiv: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllDivClockFreq(); - break; - case kClockTpmSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTpmSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmExternalFreq - * Description : Gets the external clock frequency for TPM module. - * This function gets the external clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance) -{ - sim_tpm_clk_sel_t src = CLOCK_SYS_GetTpmExternalSrc(instance); - - if (kSimTpmClkSel0 == src) - { - return g_tpmClkFreq[0]; - } - else - { - return g_tpmClkFreq[1]; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLpuartFreq - * Description : Gets the clock frequency for LPUART module. - * This function gets the clock frequency for LPUART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance) -{ - clock_lpuart_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetLpuartSrc(SIM, instance); - switch (src) - { - case kClockLpuartSrcPllFllSel: - freq = CLOCK_SYS_GetPllFllDivClockFreq(); - break; - case kClockLpuartSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpuartSrcMcgIrClk: - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetRmiiFreq - * Description : Gets the clock frequency for ENET module RMII clock. - * This function gets the clock frequency for ENET moudle RMII clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance) -{ - /* get the sim clock source setting*/ - if (CLOCK_HAL_GetRmiiSrc(SIM, instance) == kClockRmiiSrcExtalClk) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); /* OSCERCLK */ - } - else - { - return g_enet1588ClkInFreq[0]; /* ENET_1588_CLKIN */ - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetTimeStampFreq - * Description : Gets the clock frequency for ENET module TIME clock. - * This function gets the clock frequency for ENET moudle TIME clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance) -{ - uint32_t freq; - clock_time_src_t src; - - src = CLOCK_HAL_GetTimeSrc(SIM, instance); - - switch(src) - { - case kClockTimeSrcCoreSysClk: /* Core/System clock. */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockTimeSrcPllFllSel: /* FLL/PLL/IRC48M. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTimeSrcOsc0erClk: /* OSCERCLK. */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTimeSrcExt: /* ENET 1588 clock in. */ - freq = g_enet1588ClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbhsSlowClockFreq - * Description : Gets the slow clock frequency for USB HS/USB PHY module. - * This function gets the clock frequency for USB HS/USB PHY module, - * used to detect wakeup and resume events. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbhsSlowClockFreq(uint32_t instance) { - - if (CLOCK_HAL_GetUsbhsSlowClockSrc(SIM, instance) == kClockUsbhsSlowClkSrcMcgIrClk) - { - return CLOCK_SYS_GetInternalRefClockFreq(); /* MCGIRCLK */ - } - else - { - return CLOCK_SYS_GetRtcFreq(0U); /* RTC 32.768kHz clock */ - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanFreq - * Description : Gets FLEXCAN clock frequency. - * This function gets the FLEXCAN clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc) -{ - if (kClockFlexcanSrcOsc0erClk == flexcanSrc) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - case 3: - case 4: - case 5: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSdhcFreq - * Description : Gets the clock frequency for SDHC module - * This function gets the clock frequency for SDHC moudle - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance) -{ - uint32_t freq; - clock_sdhc_src_t src; - - src = CLOCK_HAL_GetSdhcSrc(SIM, instance); - - switch (src) - { - case kClockSdhcSrcCoreSysClk: /* Core/system clock */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockSdhcSrcPllFllSel: /* Clock selected by SOPT2[PLLFLLSEL]. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockSdhcSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSdhcSrcExt: /* External bypass clock (SDHC0_CLKIN) */ - freq = g_sdhcClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllFllSel: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0, - kSimClockGateDac1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, - kSimClockGateFtm3 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t canGateTable[] = -{ - kSimClockGateFlexcan0, - kSimClockGateFlexcan1 -}; -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFlexcanClock - * Description : Enable the clock for FLEXCAN module - * This function enables the clock for FLEXCAN module. - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(canGateTable)/sizeof(canGateTable[0])); - - SIM_HAL_EnableClock(SIM, canGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFlexcanClock - * Description : Disable the clock for FLEXCAN module - * This function disables the clock for FLEXCAN module. - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(canGateTable)/sizeof(canGateTable[0])); - - SIM_HAL_DisableClock(SIM, canGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanGateCmd - * Description : Get the the clock gate state for FLEXCAN module - * This function will get the clock gate state for FLEXCAN module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance) -{ - assert(instance < sizeof(canGateTable)/sizeof(canGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, canGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, - kSimClockGateSpi2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1, - kSimClockGateI2c2, - kSimClockGateI2c3, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, - kSimClockGateUart3, - kSimClockGateUart4 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/* TPM instance table. */ -static const sim_clock_gate_name_t tpmGateTable[] = -{ - kSimClockGateTpm1, - kSimClockGateTpm2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableTpmClock - * Description : Enable the clock for TPM module - * This function enables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_EnableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableTpmClock - * Description : Disable the clock for TPM module - * This function disables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_DisableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmGateCmd - * Description : Get the the clock gate state for TPM module - * This function will get the clock gate state for TPM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, tpmGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK65F18/fsl_clock_MK65F18.h b/KSDK_1.2.0/platform/system/src/clock/MK65F18/fsl_clock_MK65F18.h deleted file mode 100644 index dd6d428..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK65F18/fsl_clock_MK65F18.h +++ /dev/null @@ -1,2222 +0,0 @@ -/* - * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_K65F18_H__) -#define __FSL_CLOCK_K65F18_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k64f12 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/*! @brief ENET external clock source count. */ -#define ENET_EXT_CLK_COUNT 1 -/*! @brief SDHC external clock source count. */ -#define SDHC_EXT_CLK_COUNT 1 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 -/*! @brief TPM external clock source count. */ -#define TPM_EXT_CLK_COUNT 2 - - -/*! @brief ENET external clock frequency(ENET_1588_CLKIN) */ -extern uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; -/*! @brief SDHC external clock frequency(SDHC_CLKIN). */ -extern uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; -/*! @brief TPM external clock frequency(TPM_CLK). */ -extern uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - uint8_t pllflldiv, pllfllfrac; /*!< PLL/FLL fractional divider setting */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k65f18_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider3 setting(OUTDIV3). - * - * This function sets divide value OUTDIV3. - * - * @param outdiv3 Outdivider3 setting - */ -static inline void CLOCK_SYS_SetOutDiv3(uint8_t outdiv3) -{ - CLOCK_HAL_SetOutDiv3(SIM, outdiv3); -} - -/*! - * @brief Gets the clock out divider3 setting(OUTDIV3). - * - * This function gets divide value OUTDIV3. - * - * @return Outdivider3 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv3(void) -{ - return CLOCK_HAL_GetOutDiv3(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Gets the PLL/FLL clock divided by the fractional divider. - * - * This function gets the frequency of the PLL/FLL clock divided - * by the fractional divider configured by SIM_CLKDIV3[PLLFLLFRAC, PLLFLLDIV]. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllDivClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets the OSC0ERCLK_UNDIV frequency. - * - * This function gets the undivided OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets TPM clock frequency. - * - * This function gets the TPM clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance); - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param instance IP instance. - * @param tpmSrc The value to set. - */ -static inline void CLOCK_SYS_SetTpmSrc(uint32_t instance, clock_tpm_src_t tpmSrc) -{ - CLOCK_HAL_SetTpmSrc(SIM, instance, tpmSrc); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_SYS_GetTpmSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTpmSrc(SIM, instance); -} - -/*! - * @brief Get the TPM external clock source frequency. - * - * This function gets the TPM external clock source frequency. - * - * @param instance IP instance. - * @return TPM external clock frequency. - */ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance); - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @param src TPM external clock source. - */ -static inline void CLOCK_SYS_SetTpmExternalSrc(uint32_t instance, sim_tpm_clk_sel_t src) -{ - SIM_HAL_SetTpmExternalClkPinSelMode(SIM, instance, src); -} - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @return setting Current TPM external clock source. - */ -static inline sim_tpm_clk_sel_t CLOCK_SYS_GetTpmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); -} - -/*! - * @brief Gets ethernet RMII clock source. - * - * This function gets the ethernet RMII clock source. - * - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_rmii_src_t CLOCK_SYS_GetEnetRmiiSrc(uint32_t instance) -{ - return CLOCK_HAL_GetRmiiSrc(SIM, instance); -} - -/*! - * @brief Sets ethernet RMII clock source. - * - * This function sets the ethernet RMII clock source. - * - * @param instance module device instance. - * @param rmiiSrc RMII clock source. - */ -static inline void CLOCK_SYS_SetEnetRmiiSrc(uint32_t instance, clock_rmii_src_t rmiiSrc) -{ - CLOCK_HAL_SetRmiiSrc(SIM, instance, rmiiSrc); -} - -/*! - * @brief Gets ethernet RMII clock frequency. - * - * This function gets the ethernet RMII clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance); - -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param instance module device instance. - * @param timeSrc Ethernet timestamp clock source. - */ -static inline void CLOCK_SYS_SetEnetTimeStampSrc(uint32_t instance, clock_time_src_t timeSrc) -{ - CLOCK_HAL_SetTimeSrc(SIM, instance, timeSrc); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param instance IP instance. - * - * @return Current source. - */ -static inline clock_time_src_t CLOCK_SYS_GetEnetTimeStampSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTimeSrc(SIM, instance); -} - -/*! - * @brief Gets ethernet timestamp clock frequency. - * - * This function gets the ethernet timestamp clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock source for LPUART module - * - * This function gets the clock source for LPUART module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_lpuart_src_t CLOCK_SYS_GetLpuartSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpuartSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for LPUART module - * - * This function sets the clock source for LPUART module. - * @param instance module device instance - * @param lpuartSrc Clock source. - */ -static inline void CLOCK_SYS_SetLpuartSrc(uint32_t instance, clock_lpuart_src_t lpuartSrc) -{ - CLOCK_HAL_SetLpuartSrc(SIM, instance, lpuartSrc); -} - -/*! - * @brief Gets the clock frequency for LPUART module - * - * This function gets the clock frequency for LPUART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance); - -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS moduel instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Gets the slow clock source for USB HS/USB PHY module - * - * This function gets the slow clock source for USB HS/USB PHY module, - * used to detect wakeup and resume events. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbhs_slowclk_src_t CLOCK_SYS_GetUsbhsSlowClockSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbhsSlowClockSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB HS/USB PHY module - * - * This function sets the clock source for USB HS/USB PHY module, - * used to detect wakeup and resume events. - * @param instance module device instance. - * @param usbhsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbhsSlowClockSrc(uint32_t instance, clock_usbhs_slowclk_src_t usbhsSrc) -{ - CLOCK_HAL_SetUsbhsSlowClockSrc(SIM, instance, usbhsSrc); -} - -/*! - * @brief Gets the slow clock frequency for USB HS/USB PHY module - * - * This function gets the clock frequency for USB HS/USB PHY module, - * used to detect wakeup and resume events. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbhsSlowClockFreq(uint32_t instance); - - /*! - * @brief Gets FLEXCAN clock frequency. - * - * This function gets the FLEXCAN clock frequency. - * - * @param instance module device instance - * @param flexcanSrc clock source - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc); - -/*! - * @brief Gets the clock frequency for SDHC. - * - * This function gets the clock frequency for SDHC. - * @param instance module device instance - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance); - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetSdhcSrc( uint32_t instance, - clock_sdhc_src_t setting) -{ - CLOCK_HAL_SetSdhcSrc(SIM, instance, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_SYS_GetSdhcSrc(uint32_t instance) -{ - return CLOCK_HAL_GetSdhcSrc(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for USB DCD module - * - * This function gets the clock frequency for USB DCD module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetUsbdcdFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for MPU module. - * - * This function enables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableMpuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Disable the clock for MPU module. - * - * This function disables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableMpuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Get the the clock gate state for MPU module. - * - * This function will get the clock gate state for MPU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetMpuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FLEXBUS module. - * - * This function enables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexbusClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Disable the clock for FLEXBUS module. - * - * This function disables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexbusClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Get the the clock gate state for FLEXBUS module. - * - * This function will get the clock gate state for FLEXBUS module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexbusGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Enable the clock for SDRAMC module. - * - * This function enables the clock for SDRAMC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSdramcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSdramc0); -} - -/*! - * @brief Disable the clock for SDRAMC module. - * - * This function disables the clock for SDRAMC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSdramcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSdramc0); -} - -/*! - * @brief Get the the clock gate state for SDRAMC module. - * - * This function will get the clock gate state for SDRAMC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSdramcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSdramc0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - - -/*! - * @brief Enable the clock for TPM module. - * - * This function enables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableTpmClock(uint32_t instance); - -/*! - * @brief Disable the clock for TPM module. - * - * This function disables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableTpmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for TPM module. - * - * This function will get the clock gate state for TPM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for CMT module. - * - * This function enables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmtClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Disable the clock for CMT module. - * - * This function disables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmtClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Get the the clock gate state for CMT module. - * - * This function will get the clock gate state for CMT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmtGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Enable the clock for ENET module. - * - * This function enables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEnetClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Disable the clock for ENET module. - * - * This function disables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEnetClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Get the the clock gate state for ENET module. - * - * This function will get the clock gate state for ENET module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEnetGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for USBDCD module. - * - * This function enables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Disable the clock for USBDCD module. - * - * This function disables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Get the the clock gate state for USBDCD module. - * - * This function will get the clock gate state for USBDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Enable the clock for USBHS module. - * - * This function enables the clock for USBHS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbhsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbhs0); -} - -/*! - * @brief Disable the clock for USBHS module. - * - * This function disables the clock for USBHS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbhsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbhs0); -} - -/*! - * @brief Get the the clock gate state for USBHS module. - * - * This function will get the clock gate state for USBHS module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbhsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbhs0); -} - -/*! - * @brief Enable the clock for USBPHY module. - * - * This function enables the clock for USBPHY module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbphyClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbhsphy0); -} - -/*! - * @brief Disable the clock for USBPHY module. - * - * This function disables the clock for USBPHY module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbphyClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbhsphy0); -} - -/*! - * @brief Get the the clock gate state for USBPHY module. - * - * This function will get the clock gate state for USBPHY module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbphyGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbhsphy0); -} - -/*! - * @brief Enable the clock for USBHSDCD module. - * - * This function enables the clock for USBHSDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbhsdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbhsdcd0); -} - -/*! - * @brief Disable the clock for USBHSDCD module. - * - * This function disables the clock for USBHSDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbhsdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbhsdcd0); -} - -/*! - * @brief Get the the clock gate state for USBHSDCD module. - * - * This function will get the clock gate state for USBHSDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbhsdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbhsdcd0); -} - -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance); - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for LPUART module. - * - * This function enables the clock for LPUART module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLpuartClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Disable the clock for LPUART module. - * - * This function disables the clock for LPUART module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLpuartClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Get the the clock gate state for LPUART module. - * - * This function will get the clock gate state for LPUART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLpuartGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Enable the clock for SDHC module. - * - * This function enables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSdhcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Disable the clock for SDHC module. - * - * This function disables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSdhcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Get the the clock gate state for SDHC module. - * - * This function will get the clock gate state for SDHC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSdhcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Enable the clock for TSI module. - * - * This function enables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTsiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Disable the clock for TSI module. - * - * This function disables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTsiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Get the the clock gate state for TSI module. - * - * This function will get the clock gate state for TSI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTsiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Set the ENET external clock frequency(ENET_1588_CLKIN). - * - * This function sets the ENET external clock frequency (ENET_1588_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetEnetExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < ENET_EXT_CLK_COUNT); - - g_enet1588ClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the SDHC external clock frequency(SDHC_CLKIN). - * - * This function sets the SDHC external clock frequency (SDHC_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetSdhcExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < SDHC_EXT_CLK_COUNT); - - g_sdhcClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_K65F18_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MK66F18/fsl_clock_MK66F18.c b/KSDK_1.2.0/platform/system/src/clock/MK66F18/fsl_clock_MK66F18.c deleted file mode 100755 index 26a52a0..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK66F18/fsl_clock_MK66F18.c +++ /dev/null @@ -1,1275 +0,0 @@ -/* - * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; /* ENET_1588_CLKIN */ -uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; /* SDHC_CLKIN */ -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ -uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; /* TPM_CLK */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - CLOCK_HAL_SetPllFllDiv(SIM, simConfig->pllflldiv, simConfig->pllfllfrac); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 3U, 7U, 7U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlexBusClock: - *frequency = CLOCK_SYS_GetFlexbusFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kOsc0ErClockUndiv: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgExtPllClock: - *frequency = CLOCK_HAL_GetExtPllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kIrc48mClock: - *frequency = CPU_INTERNAL_IRC_48M; - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexbusFreq - * Description : Gets the clock frequency for FLEXBUS module - * This function gets the clock frequency for FLEXBUS module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexbusFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv3(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockPllFllSelUsb1pfd: - freq = CLOCK_HAL_GetExtPllClk(MCG); - break; - case kClockPllFllSelIrc48M: - freq = CPU_INTERNAL_IRC_48M; - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllDivClockFreq - * Description : Gets the PLL/FLL clock divided by the fractional divider. - * This function gets the frequency of the PLL/FLL clock divided - * by the fractional divider configured by SIM_CLKDIV3[PLLFLLFRAC, PLLFLLDIV]. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllDivClockFreq(void) -{ - uint32_t freq; - uint8_t pllflldiv, pllfllfrac; - - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetPllFllDiv(SIM, &pllflldiv, &pllfllfrac); - return freq * (pllfllfrac + 1) / (pllflldiv + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq - * Description : Gets OSC0ERCLKUDIV. - * This function gets the OSC0 external reference undivided frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq() - >> OSC_HAL_GetExternalRefClkDiv(g_oscBase[0]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - uint32_t freq; - uint8_t tracediv, tracefrac; - - if (kClockTraceSrcMcgoutClkDiv == src) - { - freq = CLOCK_HAL_GetOutClk(MCG); - CLOCK_HAL_GetTraceDiv(SIM, &tracediv, &tracefrac); - return freq * (tracefrac + 1) / (tracediv + 1); - } - else - { - freq = CLOCK_SYS_GetCoreClockFreq(); - } - return freq / 2U; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClkUndiv: /* OSC0ERCLKUDIV clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmfFreq - * Description : Gets the clock frequency for TPM module. - * This function gets the clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance) -{ - uint32_t freq; - clock_tpm_src_t src; - - src = CLOCK_HAL_GetTpmSrc(SIM, instance); - - switch(src) - { - case kClockTpmSrcPllFllSelDiv: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllDivClockFreq(); - break; - case kClockTpmSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTpmSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmExternalFreq - * Description : Gets the external clock frequency for TPM module. - * This function gets the external clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance) -{ - sim_tpm_clk_sel_t src = CLOCK_SYS_GetTpmExternalSrc(instance); - - if (kSimTpmClkSel0 == src) - { - return g_tpmClkFreq[0]; - } - else - { - return g_tpmClkFreq[1]; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLpuartFreq - * Description : Gets the clock frequency for LPUART module. - * This function gets the clock frequency for LPUART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance) -{ - clock_lpuart_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetLpuartSrc(SIM, instance); - switch (src) - { - case kClockLpuartSrcPllFllSel: - freq = CLOCK_SYS_GetPllFllDivClockFreq(); - break; - case kClockLpuartSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpuartSrcMcgIrClk: - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetRmiiFreq - * Description : Gets the clock frequency for ENET module RMII clock. - * This function gets the clock frequency for ENET moudle RMII clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance) -{ - /* get the sim clock source setting*/ - if (CLOCK_HAL_GetRmiiSrc(SIM, instance) == kClockRmiiSrcExtalClk) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); /* OSCERCLK */ - } - else - { - return g_enet1588ClkInFreq[0]; /* ENET_1588_CLKIN */ - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEnetTimeStampFreq - * Description : Gets the clock frequency for ENET module TIME clock. - * This function gets the clock frequency for ENET moudle TIME clock. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance) -{ - uint32_t freq; - clock_time_src_t src; - - src = CLOCK_HAL_GetTimeSrc(SIM, instance); - - switch(src) - { - case kClockTimeSrcCoreSysClk: /* Core/System clock. */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockTimeSrcPllFllSel: /* FLL/PLL/IRC48M. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTimeSrcOsc0erClk: /* OSCERCLK. */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTimeSrcExt: /* ENET 1588 clock in. */ - freq = g_enet1588ClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbhsSlowClockFreq - * Description : Gets the slow clock frequency for USB HS/USB PHY module. - * This function gets the clock frequency for USB HS/USB PHY module, - * used to detect wakeup and resume events. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbhsSlowClockFreq(uint32_t instance) { - - if (CLOCK_HAL_GetUsbhsSlowClockSrc(SIM, instance) == kClockUsbhsSlowClkSrcMcgIrClk) - { - return CLOCK_SYS_GetInternalRefClockFreq(); /* MCGIRCLK */ - } - else - { - return CLOCK_SYS_GetRtcFreq(0U); /* RTC 32.768kHz clock */ - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanFreq - * Description : Gets FLEXCAN clock frequency. - * This function gets the FLEXCAN clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc) -{ - if (kClockFlexcanSrcOsc0erClk == flexcanSrc) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - case 3: - case 4: - case 5: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSdhcFreq - * Description : Gets the clock frequency for SDHC module - * This function gets the clock frequency for SDHC moudle - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance) -{ - uint32_t freq; - clock_sdhc_src_t src; - - src = CLOCK_HAL_GetSdhcSrc(SIM, instance); - - switch (src) - { - case kClockSdhcSrcCoreSysClk: /* Core/system clock */ - freq = CLOCK_SYS_GetCoreClockFreq(); - break; - case kClockSdhcSrcPllFllSel: /* Clock selected by SOPT2[PLLFLLSEL]. */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockSdhcSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSdhcSrcExt: /* External bypass clock (SDHC0_CLKIN) */ - freq = g_sdhcClkInFreq[0]; - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllFllSel: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0, - kSimClockGateDac1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, - kSimClockGateFtm3 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t canGateTable[] = -{ - kSimClockGateFlexcan0, - kSimClockGateFlexcan1 -}; -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFlexcanClock - * Description : Enable the clock for FLEXCAN module - * This function enables the clock for FLEXCAN module. - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(canGateTable)/sizeof(canGateTable[0])); - - SIM_HAL_EnableClock(SIM, canGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFlexcanClock - * Description : Disable the clock for FLEXCAN module - * This function disables the clock for FLEXCAN module. - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance) -{ - assert(instance < sizeof(canGateTable)/sizeof(canGateTable[0])); - - SIM_HAL_DisableClock(SIM, canGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanGateCmd - * Description : Get the the clock gate state for FLEXCAN module - * This function will get the clock gate state for FLEXCAN module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance) -{ - assert(instance < sizeof(canGateTable)/sizeof(canGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, canGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, - kSimClockGateSpi2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1, - kSimClockGateI2c2, - kSimClockGateI2c3, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, - kSimClockGateUart3, - kSimClockGateUart4 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/* TPM instance table. */ -static const sim_clock_gate_name_t tpmGateTable[] = -{ - kSimClockGateTpm1, - kSimClockGateTpm2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableTpmClock - * Description : Enable the clock for TPM module - * This function enables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_EnableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableTpmClock - * Description : Disable the clock for TPM module - * This function disables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_DisableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmGateCmd - * Description : Get the the clock gate state for TPM module - * This function will get the clock gate state for TPM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, tpmGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MK66F18/fsl_clock_MK66F18.h b/KSDK_1.2.0/platform/system/src/clock/MK66F18/fsl_clock_MK66F18.h deleted file mode 100644 index 8fca5cd..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MK66F18/fsl_clock_MK66F18.h +++ /dev/null @@ -1,2222 +0,0 @@ -/* - * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_K66F18_H__) -#define __FSL_CLOCK_K66F18_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_k64f12 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/*! @brief ENET external clock source count. */ -#define ENET_EXT_CLK_COUNT 1 -/*! @brief SDHC external clock source count. */ -#define SDHC_EXT_CLK_COUNT 1 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 -/*! @brief TPM external clock source count. */ -#define TPM_EXT_CLK_COUNT 2 - - -/*! @brief ENET external clock frequency(ENET_1588_CLKIN) */ -extern uint32_t g_enet1588ClkInFreq[ENET_EXT_CLK_COUNT]; -/*! @brief SDHC external clock frequency(SDHC_CLKIN). */ -extern uint32_t g_sdhcClkInFreq[SDHC_EXT_CLK_COUNT]; -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; -/*! @brief TPM external clock frequency(TPM_CLK). */ -extern uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - uint8_t pllflldiv, pllfllfrac; /*!< PLL/FLL fractional divider setting */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_k66f18_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider3 setting(OUTDIV3). - * - * This function sets divide value OUTDIV3. - * - * @param outdiv3 Outdivider3 setting - */ -static inline void CLOCK_SYS_SetOutDiv3(uint8_t outdiv3) -{ - CLOCK_HAL_SetOutDiv3(SIM, outdiv3); -} - -/*! - * @brief Gets the clock out divider3 setting(OUTDIV3). - * - * This function gets divide value OUTDIV3. - * - * @return Outdivider3 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv3(void) -{ - return CLOCK_HAL_GetOutDiv3(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Gets the PLL/FLL clock divided by the fractional divider. - * - * This function gets the frequency of the PLL/FLL clock divided - * by the fractional divider configured by SIM_CLKDIV3[PLLFLLFRAC, PLLFLLDIV]. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllDivClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets the OSC0ERCLK_UNDIV frequency. - * - * This function gets the undivided OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets TPM clock frequency. - * - * This function gets the TPM clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance); - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param instance IP instance. - * @param tpmSrc The value to set. - */ -static inline void CLOCK_SYS_SetTpmSrc(uint32_t instance, clock_tpm_src_t tpmSrc) -{ - CLOCK_HAL_SetTpmSrc(SIM, instance, tpmSrc); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_SYS_GetTpmSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTpmSrc(SIM, instance); -} - -/*! - * @brief Get the TPM external clock source frequency. - * - * This function gets the TPM external clock source frequency. - * - * @param instance IP instance. - * @return TPM external clock frequency. - */ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance); - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @param src TPM external clock source. - */ -static inline void CLOCK_SYS_SetTpmExternalSrc(uint32_t instance, sim_tpm_clk_sel_t src) -{ - SIM_HAL_SetTpmExternalClkPinSelMode(SIM, instance, src); -} - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @return setting Current TPM external clock source. - */ -static inline sim_tpm_clk_sel_t CLOCK_SYS_GetTpmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); -} - -/*! - * @brief Gets ethernet RMII clock source. - * - * This function gets the ethernet RMII clock source. - * - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_rmii_src_t CLOCK_SYS_GetEnetRmiiSrc(uint32_t instance) -{ - return CLOCK_HAL_GetRmiiSrc(SIM, instance); -} - -/*! - * @brief Sets ethernet RMII clock source. - * - * This function sets the ethernet RMII clock source. - * - * @param instance module device instance. - * @param rmiiSrc RMII clock source. - */ -static inline void CLOCK_SYS_SetEnetRmiiSrc(uint32_t instance, clock_rmii_src_t rmiiSrc) -{ - CLOCK_HAL_SetRmiiSrc(SIM, instance, rmiiSrc); -} - -/*! - * @brief Gets ethernet RMII clock frequency. - * - * This function gets the ethernet RMII clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetRmiiFreq(uint32_t instance); - -/*! - * @brief Set the ethernet timestamp clock source selection. - * - * This function sets the ethernet timestamp clock source selection. - * - * @param instance module device instance. - * @param timeSrc Ethernet timestamp clock source. - */ -static inline void CLOCK_SYS_SetEnetTimeStampSrc(uint32_t instance, clock_time_src_t timeSrc) -{ - CLOCK_HAL_SetTimeSrc(SIM, instance, timeSrc); -} - -/*! - * @brief Get the ethernet timestamp clock source selection. - * - * This function gets the ethernet timestamp clock source selection. - * - * @param instance IP instance. - * - * @return Current source. - */ -static inline clock_time_src_t CLOCK_SYS_GetEnetTimeStampSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTimeSrc(SIM, instance); -} - -/*! - * @brief Gets ethernet timestamp clock frequency. - * - * This function gets the ethernet timestamp clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetEnetTimeStampFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock source for LPUART module - * - * This function gets the clock source for LPUART module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_lpuart_src_t CLOCK_SYS_GetLpuartSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpuartSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for LPUART module - * - * This function sets the clock source for LPUART module. - * @param instance module device instance - * @param lpuartSrc Clock source. - */ -static inline void CLOCK_SYS_SetLpuartSrc(uint32_t instance, clock_lpuart_src_t lpuartSrc) -{ - CLOCK_HAL_SetLpuartSrc(SIM, instance, lpuartSrc); -} - -/*! - * @brief Gets the clock frequency for LPUART module - * - * This function gets the clock frequency for LPUART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance); - -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS moduel instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Gets the slow clock source for USB HS/USB PHY module - * - * This function gets the slow clock source for USB HS/USB PHY module, - * used to detect wakeup and resume events. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbhs_slowclk_src_t CLOCK_SYS_GetUsbhsSlowClockSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbhsSlowClockSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB HS/USB PHY module - * - * This function sets the clock source for USB HS/USB PHY module, - * used to detect wakeup and resume events. - * @param instance module device instance. - * @param usbhsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbhsSlowClockSrc(uint32_t instance, clock_usbhs_slowclk_src_t usbhsSrc) -{ - CLOCK_HAL_SetUsbhsSlowClockSrc(SIM, instance, usbhsSrc); -} - -/*! - * @brief Gets the slow clock frequency for USB HS/USB PHY module - * - * This function gets the clock frequency for USB HS/USB PHY module, - * used to detect wakeup and resume events. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbhsSlowClockFreq(uint32_t instance); - - /*! - * @brief Gets FLEXCAN clock frequency. - * - * This function gets the FLEXCAN clock frequency. - * - * @param instance module device instance - * @param flexcanSrc clock source - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint32_t instance, clock_flexcan_src_t flexcanSrc); - -/*! - * @brief Gets the clock frequency for SDHC. - * - * This function gets the clock frequency for SDHC. - * @param instance module device instance - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSdhcFreq(uint32_t instance); - -/*! - * @brief Set the SDHC clock source selection. - * - * This function sets the SDHC clock source selection. - * - * @param instance IP instance. - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetSdhcSrc( uint32_t instance, - clock_sdhc_src_t setting) -{ - CLOCK_HAL_SetSdhcSrc(SIM, instance, setting); -} - -/*! - * @brief Get the SDHC clock source selection. - * - * This function gets the SDHC clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_sdhc_src_t CLOCK_SYS_GetSdhcSrc(uint32_t instance) -{ - return CLOCK_HAL_GetSdhcSrc(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for USB DCD module - * - * This function gets the clock frequency for USB DCD module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetUsbdcdFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for MPU module. - * - * This function enables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableMpuClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Disable the clock for MPU module. - * - * This function disables the clock for MPU module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableMpuClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Get the the clock gate state for MPU module. - * - * This function will get the clock gate state for MPU module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetMpuGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateMpu0); -} - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FLEXBUS module. - * - * This function enables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexbusClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Disable the clock for FLEXBUS module. - * - * This function disables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexbusClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Get the the clock gate state for FLEXBUS module. - * - * This function will get the clock gate state for FLEXBUS module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexbusGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Enable the clock for SDRAMC module. - * - * This function enables the clock for SDRAMC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSdramcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSdramc0); -} - -/*! - * @brief Disable the clock for SDRAMC module. - * - * This function disables the clock for SDRAMC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSdramcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSdramc0); -} - -/*! - * @brief Get the the clock gate state for SDRAMC module. - * - * This function will get the clock gate state for SDRAMC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSdramcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSdramc0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - - -/*! - * @brief Enable the clock for TPM module. - * - * This function enables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableTpmClock(uint32_t instance); - -/*! - * @brief Disable the clock for TPM module. - * - * This function disables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableTpmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for TPM module. - * - * This function will get the clock gate state for TPM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for CMT module. - * - * This function enables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmtClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Disable the clock for CMT module. - * - * This function disables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmtClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Get the the clock gate state for CMT module. - * - * This function will get the clock gate state for CMT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmtGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Enable the clock for ENET module. - * - * This function enables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEnetClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Disable the clock for ENET module. - * - * This function disables the clock for ENET module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEnetClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Get the the clock gate state for ENET module. - * - * This function will get the clock gate state for ENET module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEnetGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEnet0); -} - -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for USBDCD module. - * - * This function enables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Disable the clock for USBDCD module. - * - * This function disables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Get the the clock gate state for USBDCD module. - * - * This function will get the clock gate state for USBDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Enable the clock for USBHS module. - * - * This function enables the clock for USBHS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbhsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbhs0); -} - -/*! - * @brief Disable the clock for USBHS module. - * - * This function disables the clock for USBHS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbhsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbhs0); -} - -/*! - * @brief Get the the clock gate state for USBHS module. - * - * This function will get the clock gate state for USBHS module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbhsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbhs0); -} - -/*! - * @brief Enable the clock for USBPHY module. - * - * This function enables the clock for USBPHY module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbphyClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbhsphy0); -} - -/*! - * @brief Disable the clock for USBPHY module. - * - * This function disables the clock for USBPHY module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbphyClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbhsphy0); -} - -/*! - * @brief Get the the clock gate state for USBPHY module. - * - * This function will get the clock gate state for USBPHY module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbphyGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbhsphy0); -} - -/*! - * @brief Enable the clock for USBHSDCD module. - * - * This function enables the clock for USBHSDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbhsdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbhsdcd0); -} - -/*! - * @brief Disable the clock for USBHSDCD module. - * - * This function disables the clock for USBHSDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbhsdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbhsdcd0); -} - -/*! - * @brief Get the the clock gate state for USBHSDCD module. - * - * This function will get the clock gate state for USBHSDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbhsdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbhsdcd0); -} - -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFlexcanClock(uint32_t instance); - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFlexcanClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for LPUART module. - * - * This function enables the clock for LPUART module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLpuartClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Disable the clock for LPUART module. - * - * This function disables the clock for LPUART module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLpuartClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Get the the clock gate state for LPUART module. - * - * This function will get the clock gate state for LPUART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLpuartGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Enable the clock for SDHC module. - * - * This function enables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSdhcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Disable the clock for SDHC module. - * - * This function disables the clock for SDHC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSdhcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Get the the clock gate state for SDHC module. - * - * This function will get the clock gate state for SDHC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSdhcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSdhc0); -} - -/*! - * @brief Enable the clock for TSI module. - * - * This function enables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTsiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Disable the clock for TSI module. - * - * This function disables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTsiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Get the the clock gate state for TSI module. - * - * This function will get the clock gate state for TSI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTsiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Set the ENET external clock frequency(ENET_1588_CLKIN). - * - * This function sets the ENET external clock frequency (ENET_1588_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetEnetExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < ENET_EXT_CLK_COUNT); - - g_enet1588ClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the SDHC external clock frequency(SDHC_CLKIN). - * - * This function sets the SDHC external clock frequency (SDHC_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetSdhcExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < SDHC_EXT_CLK_COUNT); - - g_sdhcClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_K66F18_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL02Z4/fsl_clock_MKL02Z4.c b/KSDK_1.2.0/platform/system/src/clock/MKL02Z4/fsl_clock_MKL02Z4.c deleted file mode 100755 index ef0df2f..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL02Z4/fsl_clock_MKL02Z4.c +++ /dev/null @@ -1,723 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" -#include "fsl_mcg_hal.h" -#include "fsl_osc_hal.h" -#include "fsl_clock_manager.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; /* TPM_CLK */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - 0U, - 0U, - simConfig->outdiv4); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - - CLOCK_HAL_SetOutDiv(SIM, 1U, 0U, 0U, 7U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - - /*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the systen clock frequency. - * This function gets the systen clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFllClockFreq - * Description : Gets the MCGFLLCLK. - * This function gets the frequency of the MCGFLLCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFllClockFreq(void) -{ - return CLOCK_HAL_GetFllClk(MCG); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCopFreq - * Description : Gets COP clock frequency. - * This function gets the COP clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCopFreq(uint32_t instance, clock_cop_src_t copSrc) -{ - if (kClockCopSrcLpoClk == copSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmfFreq - * Description : Gets the clock frequency for TPM module. - * This function gets the clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance) -{ - uint32_t freq; - clock_tpm_src_t src; - - src = CLOCK_HAL_GetTpmSrc(SIM, instance); - - switch(src) - { - case kClockTpmSrcFll: /* FLL */ - freq = CLOCK_SYS_GetFllClockFreq(); - break; - case kClockTpmSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTpmSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmExternalFreq - * Description : Gets the external clock frequency for TPM module. - * This function gets the external clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance) -{ - sim_tpm_clk_sel_t src = CLOCK_SYS_GetTpmExternalSrc(instance); - - if (kSimTpmClkSel0 == src) - { - return g_tpmClkFreq[0]; - } - else - { - return g_tpmClkFreq[1]; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpifFreq - * Description : Gets the clock frequency for SPI module. - * This function gets the clock frequency for SPI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetBusClockFreq(); /* BUS CLOCK */ - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cfFreq - * Description : Gets the clock frequency for I2C module. - * This function gets the clock frequency for I2C moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetBusClockFreq(); /* BUS CLOCK */ - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); /* SYSTEM CLOCK*/ - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLpsciFreq - * Description : Gets the clock frequency for LPSCI module. - * This function gets the clock frequency for LPSCI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpsciFreq(uint32_t instance) -{ - uint32_t freq; - clock_lpsci_src_t src; - - src = CLOCK_HAL_GetLpsciSrc(SIM, instance); - - switch(src) - { - case kClockLpsciSrcFll: /* FLL */ - freq = CLOCK_SYS_GetFllClockFreq(); - break; - case kClockLpsciSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpsciSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Lpsci instance table. */ -static const sim_clock_gate_name_t lpsciGateTable[] = -{ - kSimClockGateLpsci0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableLpsciClock - * Description : Enable the clock for LPSCI module - * This function disable the clock for LPSCI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableLpsciClock(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - SIM_HAL_DisableClock(SIM, lpsciGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetLpsciGateCmd - * Description : Get the the clock gate state for LPSCI module - * This function will get the clock gate state for LPSCI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetLpsciGateCmd(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, lpsciGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableLpsciClock - * Description : Enable the clock for LPSCI module - * This function enables the clock for LPSCI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableLpsciClock(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - SIM_HAL_EnableClock(SIM, lpsciGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t tpmGateTable[] = -{ - kSimClockGateTpm0, - kSimClockGateTpm1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableTpmClock - * Description : Enable the clock for TPM module - * This function enables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_EnableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableTpmClock - * Description : Disable the clock for TPM module - * This function disables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_DisableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmGateCmd - * Description : Get the the clock gate state for TPM module - * This function will get the clock gate state for TPM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, tpmGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL02Z4/fsl_clock_MKL02Z4.h b/KSDK_1.2.0/platform/system/src/clock/MKL02Z4/fsl_clock_MKL02Z4.h deleted file mode 100644 index cf7837d..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL02Z4/fsl_clock_MKL02Z4.h +++ /dev/null @@ -1,675 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KL02Z4_H__) -#define __FSL_CLOCK_KL02Z4_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kl02z4 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief TPM external clock source count. */ -#define TPM_EXT_CLK_COUNT 2 - -/*! @brief TPM external clock frequency(TPM_CLK). */ -extern uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - uint8_t outdiv1, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kl02z4_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get the MCGFLLCLK clock frequency. - * - * This function gets the frequency of the MCGFLLCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetFllClockFreq(void); - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - -/*! - * @brief Gets the COP clock frequency. - * - * This function gets the COP clock frequency. - * - * @param instance module device instance - * @param copSrc COP clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetCopFreq(uint32_t instance, clock_cop_src_t copSrc); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets TPM clock frequency. - * - * This function gets the TPM clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance); - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param instance IP instance. - * @param tpmSrc The value to set. - */ -static inline void CLOCK_SYS_SetTpmSrc(uint32_t instance, clock_tpm_src_t tpmSrc) -{ - CLOCK_HAL_SetTpmSrc(SIM, instance, tpmSrc); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_SYS_GetTpmSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTpmSrc(SIM, instance); -} - -/*! - * @brief Get the TPM external clock source frequency. - * - * This function gets the TPM external clock source frequency. - * - * @param instance IP instance. - * @return TPM external clock frequency. - */ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance); - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @param src TPM external clock source. - */ -static inline void CLOCK_SYS_SetTpmExternalSrc(uint32_t instance, sim_tpm_clk_sel_t src) -{ - SIM_HAL_SetTpmExternalClkPinSelMode(SIM, instance, src); -} - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @return setting Current TPM external clock source. - */ -static inline sim_tpm_clk_sel_t CLOCK_SYS_GetTpmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance); - - /*! - * @brief Gets the clock frequency for LPSCI module. - * - * This function gets the clock frequency for LPSCI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpsciFreq(uint32_t instance); - -/*! - * @brief Set the LPSCI clock source selection. - * - * This function sets the LPSCI clock source selection. - * - * @param instance IP instance. - * @param lpsciSrc The value to set. - */ -static inline void CLOCK_SYS_SetLpsciSrc(uint32_t instance, clock_lpsci_src_t lpsciSrc) -{ - CLOCK_HAL_SetLpsciSrc(SIM, instance, lpsciSrc); -} - -/*! - * @brief Get the LPSCI clock source selection. - * - * This function gets the LPSCI clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_lpsci_src_t CLOCK_SYS_GetLpsciSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpsciSrc(SIM, instance); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Enable the clock for TPM module. - * - * This function enables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableTpmClock(uint32_t instance); - -/*! - * @brief Disable the clock for TPM module. - * - * This function disables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableTpmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for TPM module. - * - * This function will get the clock gate state for TPM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for LPSCI module. - * - * This function enables the clock for LPSCI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableLpsciClock(uint32_t instance); - -/*! - * @brief Disable the clock for LPSCI module. - * - * This function disables the clock for LPSCI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableLpsciClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for LPSCI module. - * - * This function will get the clock gate state for LPSCI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetLpsciGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Set the TPM external clock frequency(TPM_CLKx). - * - * This function sets the TPM external clock frequency (TPM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetTpmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < TPM_EXT_CLK_COUNT); - - g_tpmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KL02Z4_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL03Z4/fsl_clock_MKL03Z4.c b/KSDK_1.2.0/platform/system/src/clock/MKL03Z4/fsl_clock_MKL03Z4.c deleted file mode 100755 index fe9a81d..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL03Z4/fsl_clock_MKL03Z4.c +++ /dev/null @@ -1,704 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcglite_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* -* README: -* This file should provide these APIs: -* 1. APIs to get the frequency of output clocks in Reference Manual -> -* Chapter Clock Distribution -> Figure Clocking diagram. -* 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution -* -> Module clocks. -*/ - -/******************************************************************************* -* Definitions -******************************************************************************/ -uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; /* TPM_CLK */ - -/******************************************************************************* -* Code -******************************************************************************/ - - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - 0U, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 1U, 0U, 0U, 7U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgliteMode(&config->mcgliteConfig); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kIrc48mClock: - *frequency = kMcgliteConst48M; - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetCoreClockFreq -* Description : Gets the core clock frequency. -* This function gets the core clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetSystemClockFreq -* Description : Gets the systen clock frequency. -* This function gets the systen clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetBusClockFreq -* Description : Gets the bus clock frequency. -* This function gets the bus clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetFlashClockFreq -* Description : Gets the flash clock frequency. -* This function gets the flash clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetRtcOutFreq -* Description : Gets the RTC_CLKOUT frequency. -* This function gets RTC_CLKOUT clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return 1U; - } - else - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcFreq - * Description : Gets rtc clock frequency. - * This function gets rtc clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetExternalRefClockFreq -* Description : Gets the ERCLK32K clock frequency. -* This function gets the external reference (ERCLK32K) clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq -* Description : Gets OSC0ERCLK. -* This function gets the OSC0 external reference frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetTpmFreq -* Description : Gets the clock frequency for TPM module. -* This function gets the clock frequency for TPM moudle. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance) -{ - - clock_tpm_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetTpmSrc(SIM, instance); - - switch (src) - { - case kClockTpmSrcIrc48M: /* IRC48M */ - freq = kMcgliteConst48M; - break; - case kClockTpmSrcOsc0erClk: /* OSCER clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTpmSrcMcgIrClk: /* MCGIR clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; - -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetLpuartFreq -* Description : Gets the clock frequency for LPUART module. -* This function gets the clock frequency for LPUART moudle. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance) -{ - - clock_lpuart_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetLpuartSrc(SIM, instance); - - switch (src) - { - case kClockLpuartSrcIrc48M: /* IRC48M */ - freq = kMcgliteConst48M; - break; - case kClockLpuartSrcOsc0erClk: /* OSCER clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpuartSrcMcgIrClk: /* MCGIR clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; - -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetTpmExternalFreq -* Description : Gets Tpm external clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance) -{ - sim_tpm_clk_sel_t sel = SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); - - if (kSimTpmClkSel0 == sel) - { - return g_tpmClkFreq[0]; - } - else - { - return g_tpmClkFreq[1]; - } -} - - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnablePortClock -* Description : Enable the clock for PORT module -* This function enables the clock for PORT moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisablePortClock -* Description : Disable the clock for PORT module -* This function disables the clock for PORT moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetPortGateCmd -* Description : Get the the clock gate state for PORT module -* This function will get the clock gate state for PORT moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableAdcClock -* Description : Enable the clock for ADC module -* This function enables the clock for ADC moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableAdcClock -* Description : Disable the clock for ADC module -* This function disables the clock for ADC moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetAdcGateCmd -* Description : Get the the clock gate state for ADC module -* This function will get the clock gate state for ADC moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableSpiClock -* Description : Enable the clock for SPI module -* This function enables the clock for SPI moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableSpiClock -* Description : Disable the clock for SPI module -* This function disables the clock for SPI moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetSpiGateCmd -* Description : Get the the clock gate state for SPI module -* This function will get the clock gate state for SPI moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableI2cClock -* Description : Enable the clock for I2C module -* This function enables the clock for I2C moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableI2cClock -* Description : Disable the clock for I2C module -* This function disables the clock for I2C moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetI2cGateCmd -* Description : Get the the clock gate state for I2C module -* This function will get the clock gate state for I2C moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Lpuart instance table. */ -static const sim_clock_gate_name_t lpuartGateTable[] = -{ - kSimClockGateLpuart0 -}; - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_EnableUartClock -* Description : Enable the clock for UART module -* This function enables the clock for UART moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableLpuartClock(uint32_t instance) -{ - assert(instance < sizeof(lpuartGateTable)/sizeof(lpuartGateTable[0])); - - SIM_HAL_EnableClock(SIM, lpuartGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_DisableUartClock -* Description : Disable the clock for UART module -* This function enables the clock for UART moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableLpuartClock(uint32_t instance) -{ - assert(instance < sizeof(lpuartGateTable)/sizeof(lpuartGateTable[0])); - - SIM_HAL_DisableClock(SIM, lpuartGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_GetUartGateCmd -* Description : Get the the clock gate state for UART module -* This function will get the clock gate state for UART moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetLpuartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(lpuartGateTable)/sizeof(lpuartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, lpuartGateTable[instance]); -} - -/* TPM instance table. */ -static const sim_clock_gate_name_t tpmGateTable[] = -{ - kSimClockGateTpm0, - kSimClockGateTpm1, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableTpmClock -* Description : Enable the clock for TPM module -* This function enables the clock for TPM moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_EnableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableTpmClock -* Description : Disable the clock for TPM module -* This function disables the clock for TPM moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_DisableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetTpmGateCmd -* Description : Get the the clock gate state for TPM module -* This function will get the clock gate state for TPM moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, tpmGateTable[instance]); -} - -/******************************************************************************* -* EOF -******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL03Z4/fsl_clock_MKL03Z4.h b/KSDK_1.2.0/platform/system/src/clock/MKL03Z4/fsl_clock_MKL03Z4.h deleted file mode 100644 index 4dcccca..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL03Z4/fsl_clock_MKL03Z4.h +++ /dev/null @@ -1,812 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#if !defined(__FSL_CLOCK_KL03Z4_H__) -#define __FSL_CLOCK_KL03Z4_H__ - -#include "fsl_mcglite_hal.h" -#include "fsl_mcglite_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kl03z4 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* -* Definitions -******************************************************************************/ -/*! @brief TPM external clock source count. */ -#define TPM_EXT_CLK_COUNT 2 - -/*! @brief TPM external clock frequency(TPM_CLK). */ -extern uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kl03z4_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* -* API -******************************************************************************/ -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! -* @brief Get internal reference clock frequency. -* -* This function gets the internal reference clock frequency. -* -* @return Current clock frequency. -*/ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! -* @brief Gets the OSC0ERCLK frequency. -* -* This function gets the OSC0 external reference frequency. -* -* @return Current frequency. -*/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance); - -/*! -* @brief Gets RTC_CLKOUT frequency. -* -* This function gets the frequency of RTC_CLKOUT. -* -* @return Current frequency. -*/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! -* @brief Gets RTC_CLKOUT source. -* -* This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. -* -* @return Current source. -*/ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! -* @brief Gets RTC_CLKOUT source. -* -* This function sets the source of RTC_CLKOUT. -* -* @param src RTC_CLKOUT source to set. -*/ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetTpmFreq -* Description : Gets the clock frequency for TPM module. -* This function gets the clock frequency for TPM module. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance); - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param instance IP instance. - * @param tpmSrc The value to set. - */ -static inline void CLOCK_SYS_SetTpmSrc(uint32_t instance, clock_tpm_src_t tpmSrc) -{ - CLOCK_HAL_SetTpmSrc(SIM, instance, tpmSrc); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_SYS_GetTpmSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTpmSrc(SIM, instance); -} - -/*! - * @brief Gets the clock source for LPUART module - * - * This function gets the clock source for LPUART module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_lpuart_src_t CLOCK_SYS_GetLpuartSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpuartSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for LPUART module - * - * This function sets the clock source for LPUART module. - * @param instance module device instance - * @param lpuartSrc Clock source. - */ -static inline void CLOCK_SYS_SetLpuartSrc(uint32_t instance, clock_lpuart_src_t lpuartSrc) -{ - CLOCK_HAL_SetLpuartSrc(SIM, instance, lpuartSrc); -} - -/*! - * @brief Gets the clock frequency for LPUART module - * - * This function gets the clock frequency for LPUART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance); - - -/*! -* @brief Gets the clock frequency for FTF module. (Flash Memory) -* -* This function gets the clock frequency for FTF module. (Flash Memory) -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! -* @brief Gets the clock frequency for CMP module. -* -* This function gets the clock frequency for CMP module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets the clock frequency for VREF module. -* -* This function gets the clock frequency for VREF module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets the clock frequency for SPI module -* -* This function gets the clock frequency for SPI module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets the clock frequency for I2C module -* -* This function gets the clock frequency for I2C module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets ADC alternate clock frequency. -* -* This function gets the ADC alternate clock frequency. -* -* @param instance module device instance -* @return freq Current frequency. -*/ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! -* @brief Gets the clock frequency for UART module -* -* This function gets the clock frequency for UART module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! -* @brief Gets the clock frequency for GPIO module -* -* This function gets the clock frequency for GPIO module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! -* @brief Enable the clock for PORT module. -* -* This function enables the clock for PORT module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! -* @brief Disable the clock for PORT module. -* -* This function disables the clock for PORT module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for PORT module. -* -* This function will get the clock gate state for PORT module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for FTF module. -* -* This function enables the clock for FTF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! -* @brief Disable the clock for FTF module. -* -* This function disables the clock for FTF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! -* @brief Get the the clock gate state for FTF module. -* -* This function will get the clock gate state for FTF module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! -* @brief Enable the clock for ADC module. -* -* This function enables the clock for ADC module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! -* @brief Disable the clock for ADC module. -* -* This function disables the clock for ADC module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for ADC module. -* -* This function will get the clock gate state for ADC module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for CMP module. -* -* This function enables the clock for CMP module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp0); -} - -/*! -* @brief Disable the clock for CMP module. -* -* This function disables the clock for CMP module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp0); -} - -/*! -* @brief Get the the clock gate state for CMP module. -* -* This function will get the clock gate state for CMP module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp0); -} - -/*! -* @brief Enable the clock for VREF module. -* -* This function enables the clock for VREF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! -* @brief Disable the clock for VREF module. -* -* This function disables the clock for VREF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! -* @brief Get the the clock gate state for VREF module. -* -* This function will get the clock gate state for VREF module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! -* @brief Enable the clock for LPTIMER module. -* -* This function enables the clock for LPTIMER module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! -* @brief Disable the clock for LPTIMER module. -* -* This function disables the clock for LPTIMER module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! -* @brief Get the the clock gate state for LPTIMER module. -* -* This function will get the clock gate state for LPTIMER module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! -* @brief Enable the clock for RTC module. -* -* This function enables the clock for RTC module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! -* @brief Disable the clock for RTC module. -* -* This function disables the clock for RTC module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! -* @brief Get the the clock gate state for RTC module. -* -* This function will get the clock gate state for RTC module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! -* @brief Enable the clock for SPI module. -* -* This function enables the clock for SPI module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! -* @brief Disable the clock for SPI module. -* -* This function disables the clock for SPI module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for SPI module. -* -* This function will get the clock gate state for SPI module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for I2C module. -* -* This function enables the clock for I2C module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! -* @brief Disable the clock for I2C module. -* -* This function disables the clock for I2C module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for I2C module. -* -* This function will get the clock gate state for I2C module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for UART module. -* -* This function enables the clock for UART module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableLpuartClock(uint32_t instance); - -/*! -* @brief Disable the clock for UART module. -* -* This function disables the clock for UART module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableLpuartClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for UART module. -* -* This function will get the clock gate state for UART module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetLpuartGateCmd(uint32_t instance); - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetTpmExternalFreq -* Description : Gets Tpm external clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance); - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @param src TPM external clock source. - */ -static inline void CLOCK_SYS_SetTpmExternalSrc(uint32_t instance, sim_tpm_clk_sel_t src) -{ - SIM_HAL_SetTpmExternalClkPinSelMode(SIM, instance, src); -} - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @return setting Current TPM external clock source. - */ -static inline sim_tpm_clk_sel_t CLOCK_SYS_GetTpmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableTpmClock -* Description : Enable the clock for TPM module -* This function enables the clock for TPM module -* -*END**************************************************************************/ -void CLOCK_SYS_EnableTpmClock(uint32_t instance); - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableTpmClock -* Description : Disable the clock for TPM module -* This function disables the clock for TPM module -* -*END**************************************************************************/ -void CLOCK_SYS_DisableTpmClock(uint32_t instance); - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetTpmGateCmd -* Description : Get the the clock gate state for TPM module -* This function will get the clock gate state for TPM module. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance); - - - -/*! - * @brief Set the TPM external clock frequency(TPM_CLKx). - * - * This function sets the TPM external clock frequency (TPM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetTpmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < TPM_EXT_CLK_COUNT); - - g_tpmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - - -#endif /* __FSL_CLOCK_KL03Z4__H__ */ -/******************************************************************************* -* EOF -******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL14Z4/fsl_clock_MKL14Z4.c b/KSDK_1.2.0/platform/system/src/clock/MKL14Z4/fsl_clock_MKL14Z4.c deleted file mode 100755 index ff253b4..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL14Z4/fsl_clock_MKL14Z4.c +++ /dev/null @@ -1,986 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" -#include "fsl_mcg_hal.h" -#include "fsl_clock_manager.h" -#include "fsl_os_abstraction.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; /* TPM_CLK */ -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - 0U, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFreq - * Description : Internal function to get the frequency by clock name - * This function will get/calculate the clock frequency based on clock name - * and current configuration of clock generator. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - - CLOCK_HAL_SetOutDiv(SIM, 2U, 0U, 0U, 5U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - - /*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the systen clock frequency. - * This function gets the systen clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - freq >>= 1U; /* divided by 2 for special divider */ - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return CLOCK_SYS_GetExternalRefClock32kFreq() >> 15U; - } - else - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCopFreq - * Description : Gets cop clock frequency. - * This function gets the cop clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCopFreq(uint32_t instance, clock_cop_src_t copSrc) -{ - if (kClockCopSrcLpoClk == copSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcFreq - * Description : Gets rtc clock frequency. - * This function gets rtc clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmfFreq - * Description : Gets the clock frequency for TPM module. - * This function gets the clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance) -{ - uint32_t freq; - clock_tpm_src_t src; - - src = CLOCK_HAL_GetTpmSrc(SIM, instance); - - switch(src) - { - case kClockTpmSrcPllFllSel: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTpmSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTpmSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmExternalFreq - * Description : Gets the external clock frequency for TPM module. - * This function gets the external clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance) -{ - sim_tpm_clk_sel_t src = CLOCK_SYS_GetTpmExternalSrc(instance); - - if (kSimTpmClkSel0 == src) - { - return g_tpmClkFreq[0]; - } - else - { - return g_tpmClkFreq[1]; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG moudle. - * - *END**************************************************************************/ -#if FSL_FEATURE_SOC_USB_COUNT -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - return freq; - } -} -#endif - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpifFreq - * Description : Gets the clock frequency for SPI module. - * This function gets the clock frequency for SPI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetBusClockFreq(); /* BUS CLOCK */ - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); /* SYSTEM CLOCK*/ - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cfFreq - * Description : Gets the clock frequency for I2C module. - * This function gets the clock frequency for I2C moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetBusClockFreq(); /* BUS CLOCK */ - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); /* SYSTEM CLOCK*/ - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLpsciFreq - * Description : Gets the clock frequency for LPSCI module. - * This function gets the clock frequency for LPSCI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpsciFreq(uint32_t instance) -{ - uint32_t freq; - clock_lpsci_src_t src; - - src = CLOCK_HAL_GetLpsciSrc(SIM, instance); - - switch(src) - { - case kClockLpsciSrcPllFllSel: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockLpsciSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpsciSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq = 0; - - switch (instance) - { - case 0: - case 1: - case 2: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - - - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -#if FSL_FEATURE_SOC_DAC_COUNT -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} -#endif - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Lpsci instance table. */ -static const sim_clock_gate_name_t lpsciGateTable[] = -{ - kSimClockGateLpsci0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableLpsciClock - * Description : Enable the clock for LPSCI module - * This function disable the clock for LPSCI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableLpsciClock(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - SIM_HAL_DisableClock(SIM, lpsciGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetLpsciGateCmd - * Description : Get the the clock gate state for LPSCI module - * This function will get the clock gate state for LPSCI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetLpsciGateCmd(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, lpsciGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableLpsciClock - * Description : Enable the clock for LPSCI module - * This function enables the clock for LPSCI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableLpsciClock(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - SIM_HAL_EnableClock(SIM, lpsciGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - (sim_clock_gate_name_t)(-1), - kSimClockGateUart1, - kSimClockGateUart2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t tpmGateTable[] = -{ - kSimClockGateTpm0, - kSimClockGateTpm1, - kSimClockGateTpm2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableTpmClock - * Description : Enable the clock for TPM module - * This function enables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_EnableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableTpmClock - * Description : Disable the clock for TPM module - * This function disables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_DisableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmGateCmd - * Description : Get the the clock gate state for TPM module - * This function will get the clock gate state for TPM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, tpmGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL14Z4/fsl_clock_MKL14Z4.h b/KSDK_1.2.0/platform/system/src/clock/MKL14Z4/fsl_clock_MKL14Z4.h deleted file mode 100644 index cde5df6..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL14Z4/fsl_clock_MKL14Z4.h +++ /dev/null @@ -1,1115 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KL14Z4_H__) -#define __FSL_CLOCK_KL14Z4_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kl14z4 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief TPM external clock source count. */ -#define TPM_EXT_CLK_COUNT 2 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 - -/*! @brief TPM external clock frequency(TPM_CLK). */ -extern uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kl14z4_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance); - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the COP clock frequency. - * - * This function gets the COP clock frequency. - * - * @param instance module device instance - * @param copSrc COP clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetCopFreq(uint32_t instance, clock_cop_src_t copSrc); -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets TPM clock frequency. - * - * This function gets the TPM clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance); - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param instance IP instance. - * @param tpmSrc The value to set. - */ -static inline void CLOCK_SYS_SetTpmSrc(uint32_t instance, clock_tpm_src_t tpmSrc) -{ - CLOCK_HAL_SetTpmSrc(SIM, instance, tpmSrc); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_SYS_GetTpmSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTpmSrc(SIM, instance); -} - -/*! - * @brief Get the TPM external clock source frequency. - * - * This function gets the TPM external clock source frequency. - * - * @param instance IP instance. - * @return TPM external clock frequency. - */ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance); - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @param src TPM external clock source. - */ -static inline void CLOCK_SYS_SetTpmExternalSrc(uint32_t instance, sim_tpm_clk_sel_t src) -{ - SIM_HAL_SetTpmExternalClkPinSelMode(SIM, instance, src); -} - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @return setting Current TPM external clock source. - */ -static inline sim_tpm_clk_sel_t CLOCK_SYS_GetTpmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ - #if FSL_FEATURE_SOC_USB_COUNT -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @param usbfsSrc The value to set. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} -#endif - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance); - - /*! - * @brief Gets the clock frequency for LPSCI module. - * - * This function gets the clock frequency for LPSCI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpsciFreq(uint32_t instance); - -/*! - * @brief Set the LPSCI clock source selection. - * - * This function sets the LPSCI clock source selection. - * - * @param instance IP instance. - * @param lpsciSrc The value to set. - */ -static inline void CLOCK_SYS_SetLpsciSrc(uint32_t instance, clock_lpsci_src_t lpsciSrc) -{ - CLOCK_HAL_SetLpsciSrc(SIM, instance, lpsciSrc); -} - -/*! - * @brief Get the LPSCI clock source selection. - * - * This function gets the LPSCI clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_lpsci_src_t CLOCK_SYS_GetLpsciSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpsciSrc(SIM, instance); -} - -/*! - * @brief Get the UART clock frequency. - * - * This function gets the UART clock frequency. - * - * @param instance IP instance. - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -#if FSL_FEATURE_SOC_DAC_COUNT -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); -#endif - -/*! - * @brief Enable the clock for TPM module. - * - * This function enables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableTpmClock(uint32_t instance); - -/*! - * @brief Disable the clock for TPM module. - * - * This function disables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableTpmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for TPM module. - * - * This function will get the clock gate state for TPM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for TSI module. - * - * This function enables the clock for TSI module. - * @param instance module device instance - */ -#if FSL_FEATURE_SOC_TSI_COUNT -static inline void CLOCK_SYS_EnableTsiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Disable the clock for TSI module. - * - * This function disables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTsiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Get the the clock gate state for TSI module. - * - * This function will get the clock gate state for TSI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTsiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTsi0); -} -#endif - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ - #if FSL_FEATURE_SOC_USB_COUNT -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} -#endif - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for LPSCI module. - * - * This function enables the clock for LPSCI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableLpsciClock(uint32_t instance); - -/*! - * @brief Disable the clock for LPSCI module. - * - * This function disables the clock for LPSCI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableLpsciClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for LPSCI module. - * - * This function will get the clock gate state for LPSCI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetLpsciGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the TPM external clock frequency(TPM_CLKx). - * - * This function sets the TPM external clock frequency (TPM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetTpmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < TPM_EXT_CLK_COUNT); - - g_tpmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KL14Z4_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL15Z4/fsl_clock_MKL15Z4.c b/KSDK_1.2.0/platform/system/src/clock/MKL15Z4/fsl_clock_MKL15Z4.c deleted file mode 100755 index ff253b4..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL15Z4/fsl_clock_MKL15Z4.c +++ /dev/null @@ -1,986 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" -#include "fsl_mcg_hal.h" -#include "fsl_clock_manager.h" -#include "fsl_os_abstraction.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; /* TPM_CLK */ -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - 0U, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFreq - * Description : Internal function to get the frequency by clock name - * This function will get/calculate the clock frequency based on clock name - * and current configuration of clock generator. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - - CLOCK_HAL_SetOutDiv(SIM, 2U, 0U, 0U, 5U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - - /*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the systen clock frequency. - * This function gets the systen clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - freq >>= 1U; /* divided by 2 for special divider */ - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return CLOCK_SYS_GetExternalRefClock32kFreq() >> 15U; - } - else - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCopFreq - * Description : Gets cop clock frequency. - * This function gets the cop clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCopFreq(uint32_t instance, clock_cop_src_t copSrc) -{ - if (kClockCopSrcLpoClk == copSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcFreq - * Description : Gets rtc clock frequency. - * This function gets rtc clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmfFreq - * Description : Gets the clock frequency for TPM module. - * This function gets the clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance) -{ - uint32_t freq; - clock_tpm_src_t src; - - src = CLOCK_HAL_GetTpmSrc(SIM, instance); - - switch(src) - { - case kClockTpmSrcPllFllSel: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTpmSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTpmSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmExternalFreq - * Description : Gets the external clock frequency for TPM module. - * This function gets the external clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance) -{ - sim_tpm_clk_sel_t src = CLOCK_SYS_GetTpmExternalSrc(instance); - - if (kSimTpmClkSel0 == src) - { - return g_tpmClkFreq[0]; - } - else - { - return g_tpmClkFreq[1]; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG moudle. - * - *END**************************************************************************/ -#if FSL_FEATURE_SOC_USB_COUNT -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - return freq; - } -} -#endif - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpifFreq - * Description : Gets the clock frequency for SPI module. - * This function gets the clock frequency for SPI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetBusClockFreq(); /* BUS CLOCK */ - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); /* SYSTEM CLOCK*/ - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cfFreq - * Description : Gets the clock frequency for I2C module. - * This function gets the clock frequency for I2C moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetBusClockFreq(); /* BUS CLOCK */ - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); /* SYSTEM CLOCK*/ - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLpsciFreq - * Description : Gets the clock frequency for LPSCI module. - * This function gets the clock frequency for LPSCI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpsciFreq(uint32_t instance) -{ - uint32_t freq; - clock_lpsci_src_t src; - - src = CLOCK_HAL_GetLpsciSrc(SIM, instance); - - switch(src) - { - case kClockLpsciSrcPllFllSel: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockLpsciSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpsciSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq = 0; - - switch (instance) - { - case 0: - case 1: - case 2: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - - - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -#if FSL_FEATURE_SOC_DAC_COUNT -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} -#endif - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Lpsci instance table. */ -static const sim_clock_gate_name_t lpsciGateTable[] = -{ - kSimClockGateLpsci0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableLpsciClock - * Description : Enable the clock for LPSCI module - * This function disable the clock for LPSCI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableLpsciClock(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - SIM_HAL_DisableClock(SIM, lpsciGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetLpsciGateCmd - * Description : Get the the clock gate state for LPSCI module - * This function will get the clock gate state for LPSCI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetLpsciGateCmd(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, lpsciGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableLpsciClock - * Description : Enable the clock for LPSCI module - * This function enables the clock for LPSCI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableLpsciClock(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - SIM_HAL_EnableClock(SIM, lpsciGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - (sim_clock_gate_name_t)(-1), - kSimClockGateUart1, - kSimClockGateUart2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t tpmGateTable[] = -{ - kSimClockGateTpm0, - kSimClockGateTpm1, - kSimClockGateTpm2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableTpmClock - * Description : Enable the clock for TPM module - * This function enables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_EnableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableTpmClock - * Description : Disable the clock for TPM module - * This function disables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_DisableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmGateCmd - * Description : Get the the clock gate state for TPM module - * This function will get the clock gate state for TPM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, tpmGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL15Z4/fsl_clock_MKL15Z4.h b/KSDK_1.2.0/platform/system/src/clock/MKL15Z4/fsl_clock_MKL15Z4.h deleted file mode 100644 index a631e82..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL15Z4/fsl_clock_MKL15Z4.h +++ /dev/null @@ -1,1115 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KL15Z4_H__) -#define __FSL_CLOCK_KL15Z4_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kl15z4 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief TPM external clock source count. */ -#define TPM_EXT_CLK_COUNT 2 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 - -/*! @brief TPM external clock frequency(TPM_CLK). */ -extern uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kl15z4_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance); - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the COP clock frequency. - * - * This function gets the COP clock frequency. - * - * @param instance module device instance - * @param copSrc COP clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetCopFreq(uint32_t instance, clock_cop_src_t copSrc); -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets TPM clock frequency. - * - * This function gets the TPM clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance); - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param instance IP instance. - * @param tpmSrc The value to set. - */ -static inline void CLOCK_SYS_SetTpmSrc(uint32_t instance, clock_tpm_src_t tpmSrc) -{ - CLOCK_HAL_SetTpmSrc(SIM, instance, tpmSrc); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_SYS_GetTpmSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTpmSrc(SIM, instance); -} - -/*! - * @brief Get the TPM external clock source frequency. - * - * This function gets the TPM external clock source frequency. - * - * @param instance IP instance. - * @return TPM external clock frequency. - */ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance); - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @param src TPM external clock source. - */ -static inline void CLOCK_SYS_SetTpmExternalSrc(uint32_t instance, sim_tpm_clk_sel_t src) -{ - SIM_HAL_SetTpmExternalClkPinSelMode(SIM, instance, src); -} - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @return setting Current TPM external clock source. - */ -static inline sim_tpm_clk_sel_t CLOCK_SYS_GetTpmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ - #if FSL_FEATURE_SOC_USB_COUNT -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @param usbfsSrc The value to set. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} -#endif - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance); - - /*! - * @brief Gets the clock frequency for LPSCI module. - * - * This function gets the clock frequency for LPSCI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpsciFreq(uint32_t instance); - -/*! - * @brief Set the LPSCI clock source selection. - * - * This function sets the LPSCI clock source selection. - * - * @param instance IP instance. - * @param lpsciSrc The value to set. - */ -static inline void CLOCK_SYS_SetLpsciSrc(uint32_t instance, clock_lpsci_src_t lpsciSrc) -{ - CLOCK_HAL_SetLpsciSrc(SIM, instance, lpsciSrc); -} - -/*! - * @brief Get the LPSCI clock source selection. - * - * This function gets the LPSCI clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_lpsci_src_t CLOCK_SYS_GetLpsciSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpsciSrc(SIM, instance); -} - -/*! - * @brief Get the UART clock frequency. - * - * This function gets the UART clock frequency. - * - * @param instance IP instance. - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -#if FSL_FEATURE_SOC_DAC_COUNT -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); -#endif - -/*! - * @brief Enable the clock for TPM module. - * - * This function enables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableTpmClock(uint32_t instance); - -/*! - * @brief Disable the clock for TPM module. - * - * This function disables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableTpmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for TPM module. - * - * This function will get the clock gate state for TPM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for TSI module. - * - * This function enables the clock for TSI module. - * @param instance module device instance - */ -#if FSL_FEATURE_SOC_TSI_COUNT -static inline void CLOCK_SYS_EnableTsiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Disable the clock for TSI module. - * - * This function disables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTsiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Get the the clock gate state for TSI module. - * - * This function will get the clock gate state for TSI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTsiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTsi0); -} -#endif - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ - #if FSL_FEATURE_SOC_USB_COUNT -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} -#endif - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for LPSCI module. - * - * This function enables the clock for LPSCI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableLpsciClock(uint32_t instance); - -/*! - * @brief Disable the clock for LPSCI module. - * - * This function disables the clock for LPSCI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableLpsciClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for LPSCI module. - * - * This function will get the clock gate state for LPSCI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetLpsciGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the TPM external clock frequency(TPM_CLKx). - * - * This function sets the TPM external clock frequency (TPM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetTpmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < TPM_EXT_CLK_COUNT); - - g_tpmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KL15Z4_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL16Z4/fsl_clock_MKL16Z4.c b/KSDK_1.2.0/platform/system/src/clock/MKL16Z4/fsl_clock_MKL16Z4.c deleted file mode 100755 index 71d7a5b..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL16Z4/fsl_clock_MKL16Z4.c +++ /dev/null @@ -1,1012 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" -#include "fsl_mcg_hal.h" -#include "fsl_clock_manager.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; /* TPM_CLK */ -#if FSL_FEATURE_SOC_USB_COUNT -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -#endif - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - 0U, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - - CLOCK_HAL_SetOutDiv(SIM, 2U, 0U, 0U, 5U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - - /*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the systen clock frequency. - * This function gets the systen clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - freq >>= 1U; /* divided by 2 for special divider */ - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return CLOCK_SYS_GetExternalRefClock32kFreq() >> 15U; - } - else - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCopFreq - * Description : Gets COP clock frequency. - * This function gets the COP clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCopFreq(uint32_t instance, clock_cop_src_t copSrc) -{ - if (kClockCopSrcLpoClk == copSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcFreq - * Description : Gets rtc clock frequency. - * This function gets rtc clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmfFreq - * Description : Gets the clock frequency for TPM module. - * This function gets the clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance) -{ - uint32_t freq; - clock_tpm_src_t src; - - src = CLOCK_HAL_GetTpmSrc(SIM, instance); - - switch(src) - { - case kClockTpmSrcPllFllSel: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTpmSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTpmSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmExternalFreq - * Description : Gets the external clock frequency for TPM module. - * This function gets the external clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance) -{ - sim_tpm_clk_sel_t src = CLOCK_SYS_GetTpmExternalSrc(instance); - - if (kSimTpmClkSel0 == src) - { - return g_tpmClkFreq[0]; - } - else - { - return g_tpmClkFreq[1]; - } -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - return freq; - } -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpifFreq - * Description : Gets the clock frequency for SPI module. - * This function gets the clock frequency for SPI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetBusClockFreq(); /* BUS CLOCK */ - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); /* SYSTEM CLOCK*/ - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cfFreq - * Description : Gets the clock frequency for I2C module. - * This function gets the clock frequency for I2C moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetBusClockFreq(); /* BUS CLOCK */ - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); /* SYSTEM CLOCK*/ - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLpsciFreq - * Description : Gets the clock frequency for LPSCI module. - * This function gets the clock frequency for LPSCI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpsciFreq(uint32_t instance) -{ - uint32_t freq; - clock_lpsci_src_t src; - - src = CLOCK_HAL_GetLpsciSrc(SIM, instance); - - switch(src) - { - case kClockLpsciSrcPllFllSel: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockLpsciSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpsciSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq = 0; - - switch (instance) - { - case 0: - case 1: - case 2: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Lpsci instance table. */ -static const sim_clock_gate_name_t lpsciGateTable[] = -{ - kSimClockGateLpsci0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableLpsciClock - * Description : Enable the clock for LPSCI module - * This function disable the clock for LPSCI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableLpsciClock(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - SIM_HAL_DisableClock(SIM, lpsciGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetLpsciGateCmd - * Description : Get the the clock gate state for LPSCI module - * This function will get the clock gate state for LPSCI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetLpsciGateCmd(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, lpsciGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableLpsciClock - * Description : Enable the clock for LPSCI module - * This function enables the clock for LPSCI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableLpsciClock(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - SIM_HAL_EnableClock(SIM, lpsciGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - (sim_clock_gate_name_t)(-1), - kSimClockGateUart1, - kSimClockGateUart2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t tpmGateTable[] = -{ - kSimClockGateTpm0, - kSimClockGateTpm1, - kSimClockGateTpm2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableTpmClock - * Description : Enable the clock for TPM module - * This function enables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_EnableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableTpmClock - * Description : Disable the clock for TPM module - * This function disables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_DisableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmGateCmd - * Description : Get the the clock gate state for TPM module - * This function will get the clock gate state for TPM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, tpmGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL16Z4/fsl_clock_MKL16Z4.h b/KSDK_1.2.0/platform/system/src/clock/MKL16Z4/fsl_clock_MKL16Z4.h deleted file mode 100644 index e2a4d49..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL16Z4/fsl_clock_MKL16Z4.h +++ /dev/null @@ -1,1237 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KL16Z4_H__) -#define __FSL_CLOCK_KL16Z4_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kl16z4 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief TPM external clock source count. */ -#define TPM_EXT_CLK_COUNT 2 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 - -/*! @brief TPM external clock frequency(TPM_CLK). */ -extern uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -#endif - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kl16z4_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the COP clock frequency. - * - * This function gets the COP clock frequency. - * - * @param instance module device instance - * @param copSrc COP clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetCopFreq(uint32_t instance, clock_cop_src_t copSrc); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets TPM clock frequency. - * - * This function gets the TPM clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance); - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param instance IP instance. - * @param tpmSrc The value to set. - */ -static inline void CLOCK_SYS_SetTpmSrc(uint32_t instance, clock_tpm_src_t tpmSrc) -{ - CLOCK_HAL_SetTpmSrc(SIM, instance, tpmSrc); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_SYS_GetTpmSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTpmSrc(SIM, instance); -} - -/*! - * @brief Get the TPM external clock source frequency. - * - * This function gets the TPM external clock source frequency. - * - * @param instance IP instance. - * @return TPM external clock frequency. - */ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance); - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @param src TPM external clock source. - */ -static inline void CLOCK_SYS_SetTpmExternalSrc(uint32_t instance, sim_tpm_clk_sel_t src) -{ - SIM_HAL_SetTpmExternalClkPinSelMode(SIM, instance, src); -} - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @return setting Current TPM external clock source. - */ -static inline sim_tpm_clk_sel_t CLOCK_SYS_GetTpmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @param usbfsSrc The value to set. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance); - - /*! - * @brief Gets the clock frequency for LPSCI module. - * - * This function gets the clock frequency for LPSCI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpsciFreq(uint32_t instance); - -/*! - * @brief Set the LPSCI clock source selection. - * - * This function sets the LPSCI clock source selection. - * - * @param instance IP instance. - * @param lpsciSrc The value to set. - */ -static inline void CLOCK_SYS_SetLpsciSrc(uint32_t instance, clock_lpsci_src_t lpsciSrc) -{ - CLOCK_HAL_SetLpsciSrc(SIM, instance, lpsciSrc); -} - -/*! - * @brief Get the LPSCI clock source selection. - * - * This function gets the LPSCI clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_lpsci_src_t CLOCK_SYS_GetLpsciSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpsciSrc(SIM, instance); -} - -/*! - * @brief Get the UART clock frequency. - * - * This function gets the UART clock frequency. - * - * @param instance IP instance. - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_LCD_COUNT -/*! - * @brief Enable the clock for SLCD module. - * - * This function enables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSlcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Disable the clock for SLCD module. - * - * This function disables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSlcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Get the the clock gate state for SLCD module. - * - * This function will get the clock gate state for SLCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSlcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Gets the frequency for SLCD default clock. - * - * This function gets the frequency for SLCD default clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdDefaultFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets the frequency for SLCD alternate clock. - * - * This function gets the frequency for SLCD alternate clock (ALTSOURCE = 0). - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAltFreq(uint32_t instance) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the frequency for SLCD alternate 2 clock. - * - * This function gets the frequency for SLCD alternate 2 clock (ALTSOURCE = 1). - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAlt2Freq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} -#endif// FSL_FEATURE_SOC_LCD_COUNT - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for TPM module. - * - * This function enables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableTpmClock(uint32_t instance); - -/*! - * @brief Disable the clock for TPM module. - * - * This function disables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableTpmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for TPM module. - * - * This function will get the clock gate state for TPM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for TSI module. - * - * This function enables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTsiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Disable the clock for TSI module. - * - * This function disables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTsiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Get the the clock gate state for TSI module. - * - * This function will get the clock gate state for TSI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTsiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTsi0); -} - - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for LPSCI module. - * - * This function enables the clock for LPSCI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableLpsciClock(uint32_t instance); - -/*! - * @brief Disable the clock for LPSCI module. - * - * This function disables the clock for LPSCI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableLpsciClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for LPSCI module. - * - * This function will get the clock gate state for LPSCI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetLpsciGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Set the TPM external clock frequency(TPM_CLKx). - * - * This function sets the TPM external clock frequency (TPM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetTpmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < TPM_EXT_CLK_COUNT); - - g_tpmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KL16Z4_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL17Z4/fsl_clock_MKL17Z4.c b/KSDK_1.2.0/platform/system/src/clock/MKL17Z4/fsl_clock_MKL17Z4.c deleted file mode 100755 index d74eea3..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL17Z4/fsl_clock_MKL17Z4.c +++ /dev/null @@ -1,840 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcglite_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* -* README: -* This file should provide these APIs: -* 1. APIs to get the frequency of output clocks in Reference Manual -> -* Chapter Clock Distribution -> Figure Clocking diagram. -* 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution -* -> Module clocks. -*/ - -/******************************************************************************* -* Definitions -******************************************************************************/ -uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; /* TPM_CLK */ -#if FSL_FEATURE_SOC_USB_COUNT -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -#endif - -/******************************************************************************* -* Code -******************************************************************************/ - - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - 0U, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 1U, 0U, 0U, 7U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgliteMode(&config->mcgliteConfig); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kIrc48mClock: - *frequency = kMcgliteConst48M; - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetCoreClockFreq -* Description : Gets the core clock frequency. -* This function gets the core clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetSystemClockFreq -* Description : Gets the systen clock frequency. -* This function gets the systen clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetBusClockFreq -* Description : Gets the bus clock frequency. -* This function gets the bus clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetFlashClockFreq -* Description : Gets the flash clock frequency. -* This function gets the flash clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetRtcOutFreq -* Description : Gets the RTC_CLKOUT frequency. -* This function gets RTC_CLKOUT clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return 1U; - } - else - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetExternalRefClockFreq -* Description : Gets the ERCLK32K clock frequency. -* This function gets the external reference (ERCLK32K) clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq -* Description : Gets OSC0ERCLK. -* This function gets the OSC0 external reference frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetCopFreq -* Description : Gets the clock frequency for COP module. -* This function gets the clock frequency for COP moudle. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetCopFreq(void) -{ - clock_cop_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetCopSrc(SIM); - - switch (src) - { - case kClockCopSrcLpoClk: - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockCopSrcMcgIrClk: - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockCopSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockCopSrcBusClk: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetTpmFreq -* Description : Gets the clock frequency for TPM module. -* This function gets the clock frequency for TPM moudle. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance) -{ - - clock_tpm_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetTpmSrc(SIM, instance); - - switch (src) - { - case kClockTpmSrcIrc48M: /* IRC48M */ - freq = kMcgliteConst48M; - break; - case kClockTpmSrcOsc0erClk: /* OSCER clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTpmSrcMcgIrClk: /* MCGIR clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetLpuartFreq -* Description : Gets the clock frequency for LPUART module. -* This function gets the clock frequency for LPUART moudle. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance) -{ - clock_lpuart_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetLpuartSrc(SIM, instance); - - switch (src) - { - case kClockLpuartSrcIrc48M: /* IRC48M */ - freq = kMcgliteConst48M; - break; - case kClockLpuartSrcOsc0erClk: /* OSCER clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpuartSrcMcgIrClk: /* MCGIR clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetTpmExternalFreq -* Description : Gets Tpm external clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance) -{ - sim_tpm_clk_sel_t sel = SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); - - if (kSimTpmClkSel0 == sel) - { - return g_tpmClkFreq[0]; - } - else - { - return g_tpmClkFreq[1]; - } -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - clock_usbfs_src_t src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; - } - else - { - return kMcgliteConst48M; - } -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexioFreq - * Description : Gets the clock frequency for FLEXIO. - * This function gets the clock frequency for FLEXIO. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexioFreq(uint32_t instance) -{ - uint32_t freq; - clock_flexio_src_t src = CLOCK_HAL_GetFlexioSrc(SIM, instance); - - switch (src) - { - case kClockFlexioSrcIrc48M: - freq = kMcgliteConst48M; - break; - case kClockFlexioSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockFlexioSrcMcgIrClk: - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcSysClk: /*!< SYSCLK */ - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case kClockSaiSrcOsc0erClk: /*!< OSC0ERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcMcgIrClk: /*!< MCGIRCLK */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockSaiSrcIrc48M: /*!< MCGPCLK/IRC48M. */ - freq = kMcgliteConst48M; - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiFreq - * Description : Gets the clock frequency for SPI. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - assert(instance < SPI_INSTANCE_COUNT); - - if (0U == instance) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetSystemClockFreq(); - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnablePortClock -* Description : Enable the clock for PORT module -* This function enables the clock for PORT moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisablePortClock -* Description : Disable the clock for PORT module -* This function disables the clock for PORT moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetPortGateCmd -* Description : Get the the clock gate state for PORT module -* This function will get the clock gate state for PORT moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableAdcClock -* Description : Enable the clock for ADC module -* This function enables the clock for ADC moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableAdcClock -* Description : Disable the clock for ADC module -* This function disables the clock for ADC moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetAdcGateCmd -* Description : Get the the clock gate state for ADC module -* This function will get the clock gate state for ADC moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableSpiClock -* Description : Enable the clock for SPI module -* This function enables the clock for SPI moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableSpiClock -* Description : Disable the clock for SPI module -* This function disables the clock for SPI moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetSpiGateCmd -* Description : Get the the clock gate state for SPI module -* This function will get the clock gate state for SPI moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableI2cClock -* Description : Enable the clock for I2C module -* This function enables the clock for I2C moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableI2cClock -* Description : Disable the clock for I2C module -* This function disables the clock for I2C moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetI2cGateCmd -* Description : Get the the clock gate state for I2C module -* This function will get the clock gate state for I2C moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Lpuart instance table. */ -static const sim_clock_gate_name_t lpuartGateTable[] = -{ - kSimClockGateLpuart0, - kSimClockGateLpuart1 -}; - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_EnableLpuartClock -* Description : Enable the clock for UART module -* This function enables the clock for UART moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableLpuartClock(uint32_t instance) -{ - assert(instance < sizeof(lpuartGateTable)/sizeof(lpuartGateTable[0])); - - SIM_HAL_EnableClock(SIM, lpuartGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_DisableLpuartClock -* Description : Disable the clock for UART module -* This function enables the clock for UART moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableLpuartClock(uint32_t instance) -{ - assert(instance < sizeof(lpuartGateTable)/sizeof(lpuartGateTable[0])); - - SIM_HAL_DisableClock(SIM, lpuartGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_GetLpuartGateCmd -* Description : Get the the clock gate state for UART module -* This function will get the clock gate state for UART moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetLpuartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(lpuartGateTable)/sizeof(lpuartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, lpuartGateTable[instance]); -} - -/* TPM instance table. */ -static const sim_clock_gate_name_t tpmGateTable[] = -{ - kSimClockGateTpm0, - kSimClockGateTpm1, - kSimClockGateTpm2, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableTpmClock -* Description : Enable the clock for TPM module -* This function enables the clock for TPM moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_EnableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableTpmClock -* Description : Disable the clock for TPM module -* This function disables the clock for TPM moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_DisableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetTpmGateCmd -* Description : Get the the clock gate state for TPM module -* This function will get the clock gate state for TPM moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, tpmGateTable[instance]); -} - -/******************************************************************************* -* EOF -******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL17Z4/fsl_clock_MKL17Z4.h b/KSDK_1.2.0/platform/system/src/clock/MKL17Z4/fsl_clock_MKL17Z4.h deleted file mode 100644 index 9cd8843..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL17Z4/fsl_clock_MKL17Z4.h +++ /dev/null @@ -1,1323 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#if !defined(__FSL_CLOCK_MKL17Z4_H__) -#define __FSL_CLOCK_MKL17Z4_H__ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcglite_hal.h" -#include "fsl_mcglite_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kl17z4 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* -* Definitions -******************************************************************************/ -/*! @brief TPM external clock source count. */ -#define TPM_EXT_CLK_COUNT 2 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 - -/*! @brief TPM external clock frequency(TPM_CLK). */ -extern uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -#endif - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kl17z4_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* -* API -******************************************************************************/ -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! -* @brief Get internal reference clock frequency. -* -* This function gets the internal reference clock frequency. -* -* @return Current clock frequency. -*/ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! -* @brief Gets the OSC0ERCLK frequency. -* -* This function gets the OSC0 external reference frequency. -* -* @return Current frequency. -*/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! -* @brief Gets RTC_CLKOUT frequency. -* -* This function gets the frequency of RTC_CLKOUT. -* -* @return Current frequency. -*/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! -* @brief Gets RTC_CLKOUT source. -* -* This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. -* -* @return Current source. -*/ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! -* @brief Gets RTC_CLKOUT source. -* -* This function sets the source of RTC_CLKOUT. -* -* @param src RTC_CLKOUT source to set. -*/ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - - /*! - * @brief Gets rtc clock frequency. - * - * This function gets the rtc clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets COP clock frequency. - * - * This function gets the COP clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetCopFreq(void); - -/*! - * @brief Set the COP clock source selection. - * - * This function sets the COP clock source selection. - * - * @param copSrc The value to set. - */ -static inline void CLOCK_SYS_SetCopSrc(clock_cop_src_t copSrc) -{ - CLOCK_HAL_SetCopSrc(SIM, copSrc); -} - -/*! - * @brief Get the COP clock source selection. - * - * This function gets the COP clock source selection. - * - * @return Current selection. - */ -static inline clock_cop_src_t CLOCK_SYS_GetCopSrc(void) -{ - return CLOCK_HAL_GetCopSrc(SIM); -} - -/*! - * @brief Gets TPM clock frequency. - * - * This function gets the TPM clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance); - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param instance IP instance. - * @param tpmSrc The value to set. - */ -static inline void CLOCK_SYS_SetTpmSrc(uint32_t instance, clock_tpm_src_t tpmSrc) -{ - CLOCK_HAL_SetTpmSrc(SIM, instance, tpmSrc); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_SYS_GetTpmSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTpmSrc(SIM, instance); -} - -/*! - * @brief Get the TPM external clock source frequency. - * - * This function gets the TPM external clock source frequency. - * - * @param instance IP instance. - * @return TPM external clock frequency. - */ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance); - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @param src TPM external clock source. - */ -static inline void CLOCK_SYS_SetTpmExternalSrc(uint32_t instance, sim_tpm_clk_sel_t src) -{ - SIM_HAL_SetTpmExternalClkPinSelMode(SIM, instance, src); -} - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @return setting Current TPM external clock source. - */ -static inline sim_tpm_clk_sel_t CLOCK_SYS_GetTpmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @param usbfsSrc The value to set. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Gets the clock source for LPUART module - * - * This function gets the clock source for LPUART module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_lpuart_src_t CLOCK_SYS_GetLpuartSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpuartSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for LPUART module - * - * This function sets the clock source for LPUART module. - * @param instance module device instance - * @param lpuartSrc Clock source. - */ -static inline void CLOCK_SYS_SetLpuartSrc(uint32_t instance, clock_lpuart_src_t lpuartSrc) -{ - CLOCK_HAL_SetLpuartSrc(SIM, instance, lpuartSrc); -} - -/*! - * @brief Gets the clock frequency for LPUART module - * - * This function gets the clock frequency for LPUART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance); - -/*! - * @brief Gets FLEXIO clock frequency. - * - * This function gets the FLEXIO clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexioFreq(uint32_t instance); - -/*! - * @brief Set the FLEXIO clock source selection. - * - * This function sets the FLEXIO clock source selection. - * - * @param instance IP instance. - * @param flexioSrc The value to set. - */ -static inline void CLOCK_SYS_SetFlexioSrc(uint32_t instance, clock_flexio_src_t flexioSrc) -{ - CLOCK_HAL_SetFlexioSrc(SIM, instance, flexioSrc); -} - -/*! - * @brief Get the FLEXIO clock source selection. - * - * This function gets the FLEXIO clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_flexio_src_t CLOCK_SYS_GetFlexioSrc(uint32_t instance) -{ - return CLOCK_HAL_GetFlexioSrc(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -#if FSL_FEATURE_SOC_LCD_COUNT -/*! - * @brief Gets the frequency for SLCD default clock. - * - * This function gets the frequency for SLCD default clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdDefaultFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets the frequency for SLCD alternate clock. - * - * This function gets the frequency for SLCD alternate clock (ALTSOURCE = 0). - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAltFreq(uint32_t instance) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the frequency for SLCD alternate 2 clock. - * - * This function gets the frequency for SLCD alternate 2 clock (ALTSOURCE = 1). - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAlt2Freq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} -#endif// FSL_FEATURE_SOC_LCD_COUNT - -/*! -* @brief Gets the clock frequency for FTF module. (Flash Memory) -* -* This function gets the clock frequency for FTF module. (Flash Memory) -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets the clock frequency for CMP module. -* -* This function gets the clock frequency for CMP module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets the clock frequency for VREF module. -* -* This function gets the clock frequency for VREF module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets the clock frequency for SPI module -* -* This function gets the clock frequency for SPI module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance); - -/*! -* @brief Gets the clock frequency for I2C module -* -* This function gets the clock frequency for I2C module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets ADC alternate clock frequency. -* -* This function gets the ADC alternate clock frequency. -* -* @param instance module device instance -* @return freq Current frequency. -*/ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! -* @brief Gets the clock frequency for UART module -* -* This function gets the clock frequency for UART module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Enable the clock for PORT module. -* -* This function enables the clock for PORT module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! -* @brief Disable the clock for PORT module. -* -* This function disables the clock for PORT module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for PORT module. -* -* This function will get the clock gate state for PORT module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_LCD_COUNT -/*! -* @brief Enable the clock for SLCD module. -* -* This function enables the clock for SLCD module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableSlcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSlcd0); -} - -/*! -* @brief Disable the clock for SLCD module. -* -* This function disables the clock for SLCD module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableSlcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSlcd0); -} - -/*! -* @brief Get the the clock gate state for SLCD module. -* -* This function will get the clock gate state for SLCD module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetSlcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSlcd0); -} -#endif// FSL_FEATURE_SOC_LCD_COUNT - -/*! -* @brief Enable the clock for FTF module. -* -* This function enables the clock for FTF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! -* @brief Disable the clock for FTF module. -* -* This function disables the clock for FTF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! -* @brief Get the the clock gate state for FTF module. -* -* This function will get the clock gate state for FTF module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! -* @brief Enable the clock for ADC module. -* -* This function enables the clock for ADC module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! -* @brief Disable the clock for ADC module. -* -* This function disables the clock for ADC module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for ADC module. -* -* This function will get the clock gate state for ADC module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for CMP module. -* -* This function enables the clock for CMP module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp0); -} - -/*! -* @brief Disable the clock for CMP module. -* -* This function disables the clock for CMP module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp0); -} - -/*! -* @brief Get the the clock gate state for CMP module. -* -* This function will get the clock gate state for CMP module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp0); -} - -/*! -* @brief Enable the clock for VREF module. -* -* This function enables the clock for VREF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! -* @brief Disable the clock for VREF module. -* -* This function disables the clock for VREF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! -* @brief Get the the clock gate state for VREF module. -* -* This function will get the clock gate state for VREF module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! -* @brief Enable the clock for LPTIMER module. -* -* This function enables the clock for LPTIMER module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! -* @brief Disable the clock for LPTIMER module. -* -* This function disables the clock for LPTIMER module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! -* @brief Get the the clock gate state for LPTIMER module. -* -* This function will get the clock gate state for LPTIMER module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! -* @brief Enable the clock for RTC module. -* -* This function enables the clock for RTC module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! -* @brief Disable the clock for RTC module. -* -* This function disables the clock for RTC module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! -* @brief Get the the clock gate state for RTC module. -* -* This function will get the clock gate state for RTC module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! -* @brief Enable the clock for DAC module. -* -* This function enables the clock for DAC module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDac0); -} - -/*! -* @brief Disable the clock for DAC module. -* -* This function disables the clock for DAC module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDac0); -} - -/*! -* @brief Get the the clock gate state for DAC module. -* -* This function will get the clock gate state for DAC module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDac0); -} - -/*! -* @brief Enable the clock for SPI module. -* -* This function enables the clock for SPI module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! -* @brief Disable the clock for SPI module. -* -* This function disables the clock for SPI module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for SPI module. -* -* This function will get the clock gate state for SPI module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for I2C module. -* -* This function enables the clock for I2C module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! -* @brief Disable the clock for I2C module. -* -* This function disables the clock for I2C module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for I2C module. -* -* This function will get the clock gate state for I2C module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for LPUART module. -* -* This function enables the clock for LPUART module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableLpuartClock(uint32_t instance); - -/*! -* @brief Disable the clock for LPUART module. -* -* This function disables the clock for LPUART module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableLpuartClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for LPUART module. -* -* This function will get the clock gate state for LPUART module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetLpuartGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for UART module. -* -* This function enables the clock for UART module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUart2); -} - -/*! -* @brief Disable the clock for UART module. -* -* This function disables the clock for UART module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUart2); -} - -/*! -* @brief Get the the clock gate state for UART module. -* -* This function will get the clock gate state for UART module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM,kSimClockGateUart2); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! -* @brief Enable the clock for FLEXIO module. -* -* This function enables the clock for FLEXIO module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableFlexioClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexio0); -} - -/*! -* @brief Disable the clock for FLEXIO module. -* -* This function disables the clock for FLEXIO module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableFlexioClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexio0); -} - -/*! -* @brief Get the clock gate state for FLEXIO module. -* -* This function will get the clock gate state for FLEXIO module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetFlexioGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM,kSimClockGateFlexio0); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for TPM module. - * - * This function enables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableTpmClock(uint32_t instance); - -/*! - * @brief Disable the clock for TPM module. - * - * This function disables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableTpmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for TPM module. - * - * This function will get the clock gate state for TPM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Set the TPM external clock frequency(TPM_CLKx). - * - * This function sets the TPM external clock frequency (TPM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetTpmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < TPM_EXT_CLK_COUNT); - - g_tpmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - - -#endif /* __FSL_CLOCK_MKL17Z4__H__ */ -/******************************************************************************* -* EOF -******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL17Z644/fsl_clock_MKL17Z644.c b/KSDK_1.2.0/platform/system/src/clock/MKL17Z644/fsl_clock_MKL17Z644.c deleted file mode 100755 index d204e3a..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL17Z644/fsl_clock_MKL17Z644.c +++ /dev/null @@ -1,804 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcglite_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* -* README: -* This file should provide these APIs: -* 1. APIs to get the frequency of output clocks in Reference Manual -> -* Chapter Clock Distribution -> Figure Clocking diagram. -* 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution -* -> Module clocks. -*/ - -/******************************************************************************* -* Definitions -******************************************************************************/ -uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; /* TPM_CLK */ -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ - -/******************************************************************************* -* Code -******************************************************************************/ - - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - 0U, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 1U, 0U, 0U, 7U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgliteMode(&config->mcgliteConfig); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kIrc48mClock: - *frequency = kMcgliteConst48M; - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetCoreClockFreq -* Description : Gets the core clock frequency. -* This function gets the core clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetSystemClockFreq -* Description : Gets the systen clock frequency. -* This function gets the systen clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetBusClockFreq -* Description : Gets the bus clock frequency. -* This function gets the bus clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetFlashClockFreq -* Description : Gets the flash clock frequency. -* This function gets the flash clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetRtcOutFreq -* Description : Gets the RTC_CLKOUT frequency. -* This function gets RTC_CLKOUT clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return 1U; - } - else - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetExternalRefClockFreq -* Description : Gets the ERCLK32K clock frequency. -* This function gets the external reference (ERCLK32K) clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq -* Description : Gets OSC0ERCLK. -* This function gets the OSC0 external reference frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetCopFreq -* Description : Gets the clock frequency for COP module. -* This function gets the clock frequency for COP moudle. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetCopFreq(void) -{ - clock_cop_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetCopSrc(SIM); - - switch (src) - { - case kClockCopSrcLpoClk: - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockCopSrcMcgIrClk: - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockCopSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockCopSrcBusClk: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetTpmFreq -* Description : Gets the clock frequency for TPM module. -* This function gets the clock frequency for TPM moudle. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance) -{ - - clock_tpm_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetTpmSrc(SIM, instance); - - switch (src) - { - case kClockTpmSrcIrc48M: /* IRC48M */ - freq = kMcgliteConst48M; - break; - case kClockTpmSrcOsc0erClk: /* OSCER clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTpmSrcMcgIrClk: /* MCGIR clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetLpuartFreq -* Description : Gets the clock frequency for LPUART module. -* This function gets the clock frequency for LPUART moudle. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance) -{ - clock_lpuart_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetLpuartSrc(SIM, instance); - - switch (src) - { - case kClockLpuartSrcIrc48M: /* IRC48M */ - freq = kMcgliteConst48M; - break; - case kClockLpuartSrcOsc0erClk: /* OSCER clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpuartSrcMcgIrClk: /* MCGIR clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetTpmExternalFreq -* Description : Gets Tpm external clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance) -{ - sim_tpm_clk_sel_t sel = SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); - - if (kSimTpmClkSel0 == sel) - { - return g_tpmClkFreq[0]; - } - else - { - return g_tpmClkFreq[1]; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - clock_usbfs_src_t src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; - } - else - { - return kMcgliteConst48M; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexioFreq - * Description : Gets the clock frequency for FLEXIO. - * This function gets the clock frequency for FLEXIO. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexioFreq(uint32_t instance) -{ - uint32_t freq; - clock_flexio_src_t src = CLOCK_HAL_GetFlexioSrc(SIM, instance); - - switch (src) - { - case kClockFlexioSrcIrc48M: - freq = kMcgliteConst48M; - break; - case kClockFlexioSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockFlexioSrcMcgIrClk: - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiFreq - * Description : Gets the clock frequency for SPI. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - assert(instance < SPI_INSTANCE_COUNT); - - if (0U == instance) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetSystemClockFreq(); - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnablePortClock -* Description : Enable the clock for PORT module -* This function enables the clock for PORT moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisablePortClock -* Description : Disable the clock for PORT module -* This function disables the clock for PORT moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetPortGateCmd -* Description : Get the the clock gate state for PORT module -* This function will get the clock gate state for PORT moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableAdcClock -* Description : Enable the clock for ADC module -* This function enables the clock for ADC moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableAdcClock -* Description : Disable the clock for ADC module -* This function disables the clock for ADC moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetAdcGateCmd -* Description : Get the the clock gate state for ADC module -* This function will get the clock gate state for ADC moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableSpiClock -* Description : Enable the clock for SPI module -* This function enables the clock for SPI moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableSpiClock -* Description : Disable the clock for SPI module -* This function disables the clock for SPI moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetSpiGateCmd -* Description : Get the the clock gate state for SPI module -* This function will get the clock gate state for SPI moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableI2cClock -* Description : Enable the clock for I2C module -* This function enables the clock for I2C moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableI2cClock -* Description : Disable the clock for I2C module -* This function disables the clock for I2C moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetI2cGateCmd -* Description : Get the the clock gate state for I2C module -* This function will get the clock gate state for I2C moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Lpuart instance table. */ -static const sim_clock_gate_name_t lpuartGateTable[] = -{ - kSimClockGateLpuart0, - kSimClockGateLpuart1 -}; - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_EnableLpuartClock -* Description : Enable the clock for UART module -* This function enables the clock for UART moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableLpuartClock(uint32_t instance) -{ - assert(instance < sizeof(lpuartGateTable)/sizeof(lpuartGateTable[0])); - - SIM_HAL_EnableClock(SIM, lpuartGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_DisableLpuartClock -* Description : Disable the clock for UART module -* This function enables the clock for UART moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableLpuartClock(uint32_t instance) -{ - assert(instance < sizeof(lpuartGateTable)/sizeof(lpuartGateTable[0])); - - SIM_HAL_DisableClock(SIM, lpuartGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_GetLpuartGateCmd -* Description : Get the the clock gate state for UART module -* This function will get the clock gate state for UART moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetLpuartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(lpuartGateTable)/sizeof(lpuartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, lpuartGateTable[instance]); -} - -/* TPM instance table. */ -static const sim_clock_gate_name_t tpmGateTable[] = -{ - kSimClockGateTpm0, - kSimClockGateTpm1, - kSimClockGateTpm2, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableTpmClock -* Description : Enable the clock for TPM module -* This function enables the clock for TPM moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_EnableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableTpmClock -* Description : Disable the clock for TPM module -* This function disables the clock for TPM moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_DisableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetTpmGateCmd -* Description : Get the the clock gate state for TPM module -* This function will get the clock gate state for TPM moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, tpmGateTable[instance]); -} - -/******************************************************************************* -* EOF -******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL17Z644/fsl_clock_MKL17Z644.h b/KSDK_1.2.0/platform/system/src/clock/MKL17Z644/fsl_clock_MKL17Z644.h deleted file mode 100644 index 3c86cb9..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL17Z644/fsl_clock_MKL17Z644.h +++ /dev/null @@ -1,1193 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#if !defined(__FSL_CLOCK_MKL17Z644_H__) -#define __FSL_CLOCK_MKL17Z644_H__ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcglite_hal.h" -#include "fsl_mcglite_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kl17z644 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* -* Definitions -******************************************************************************/ -/*! @brief TPM external clock source count. */ -#define TPM_EXT_CLK_COUNT 2 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 - -/*! @brief TPM external clock frequency(TPM_CLK). */ -extern uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kl17z644_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* -* API -******************************************************************************/ -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! -* @brief Get internal reference clock frequency. -* -* This function gets the internal reference clock frequency. -* -* @return Current clock frequency. -*/ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! -* @brief Gets the OSC0ERCLK frequency. -* -* This function gets the OSC0 external reference frequency. -* -* @return Current frequency. -*/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! -* @brief Gets RTC_CLKOUT frequency. -* -* This function gets the frequency of RTC_CLKOUT. -* -* @return Current frequency. -*/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! -* @brief Gets RTC_CLKOUT source. -* -* This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. -* -* @return Current source. -*/ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! -* @brief Gets RTC_CLKOUT source. -* -* This function sets the source of RTC_CLKOUT. -* -* @param src RTC_CLKOUT source to set. -*/ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - - /*! - * @brief Gets rtc clock frequency. - * - * This function gets the rtc clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets COP clock frequency. - * - * This function gets the COP clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetCopFreq(void); - -/*! - * @brief Set the COP clock source selection. - * - * This function sets the COP clock source selection. - * - * @param copSrc The value to set. - */ -static inline void CLOCK_SYS_SetCopSrc(clock_cop_src_t copSrc) -{ - CLOCK_HAL_SetCopSrc(SIM, copSrc); -} - -/*! - * @brief Get the COP clock source selection. - * - * This function gets the COP clock source selection. - * - * @return Current selection. - */ -static inline clock_cop_src_t CLOCK_SYS_GetCopSrc(void) -{ - return CLOCK_HAL_GetCopSrc(SIM); -} - -/*! - * @brief Gets TPM clock frequency. - * - * This function gets the TPM clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance); - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param instance IP instance. - * @param tpmSrc The value to set. - */ -static inline void CLOCK_SYS_SetTpmSrc(uint32_t instance, clock_tpm_src_t tpmSrc) -{ - CLOCK_HAL_SetTpmSrc(SIM, instance, tpmSrc); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_SYS_GetTpmSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTpmSrc(SIM, instance); -} - -/*! - * @brief Get the TPM external clock source frequency. - * - * This function gets the TPM external clock source frequency. - * - * @param instance IP instance. - * @return TPM external clock frequency. - */ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance); - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @param src TPM external clock source. - */ -static inline void CLOCK_SYS_SetTpmExternalSrc(uint32_t instance, sim_tpm_clk_sel_t src) -{ - SIM_HAL_SetTpmExternalClkPinSelMode(SIM, instance, src); -} - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @return setting Current TPM external clock source. - */ -static inline sim_tpm_clk_sel_t CLOCK_SYS_GetTpmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @param usbfsSrc The value to set. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Gets the clock source for LPUART module - * - * This function gets the clock source for LPUART module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_lpuart_src_t CLOCK_SYS_GetLpuartSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpuartSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for LPUART module - * - * This function sets the clock source for LPUART module. - * @param instance module device instance - * @param lpuartSrc Clock source. - */ -static inline void CLOCK_SYS_SetLpuartSrc(uint32_t instance, clock_lpuart_src_t lpuartSrc) -{ - CLOCK_HAL_SetLpuartSrc(SIM, instance, lpuartSrc); -} - -/*! - * @brief Gets the clock frequency for LPUART module - * - * This function gets the clock frequency for LPUART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance); - -/*! - * @brief Gets FLEXIO clock frequency. - * - * This function gets the FLEXIO clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexioFreq(uint32_t instance); - -/*! - * @brief Set the FLEXIO clock source selection. - * - * This function sets the FLEXIO clock source selection. - * - * @param instance IP instance. - * @param flexioSrc The value to set. - */ -static inline void CLOCK_SYS_SetFlexioSrc(uint32_t instance, clock_flexio_src_t flexioSrc) -{ - CLOCK_HAL_SetFlexioSrc(SIM, instance, flexioSrc); -} - -/*! - * @brief Get the FLEXIO clock source selection. - * - * This function gets the FLEXIO clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_flexio_src_t CLOCK_SYS_GetFlexioSrc(uint32_t instance) -{ - return CLOCK_HAL_GetFlexioSrc(SIM, instance); -} - -/*! -* @brief Gets the clock frequency for FTF module. (Flash Memory) -* -* This function gets the clock frequency for FTF module. (Flash Memory) -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets the clock frequency for CMP module. -* -* This function gets the clock frequency for CMP module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets the clock frequency for VREF module. -* -* This function gets the clock frequency for VREF module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets the clock frequency for SPI module -* -* This function gets the clock frequency for SPI module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance); - -/*! -* @brief Gets the clock frequency for I2C module -* -* This function gets the clock frequency for I2C module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets ADC alternate clock frequency. -* -* This function gets the ADC alternate clock frequency. -* -* @param instance module device instance -* @return freq Current frequency. -*/ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! -* @brief Gets the clock frequency for UART module -* -* This function gets the clock frequency for UART module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Enable the clock for PORT module. -* -* This function enables the clock for PORT module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! -* @brief Disable the clock for PORT module. -* -* This function disables the clock for PORT module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for PORT module. -* -* This function will get the clock gate state for PORT module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for FTF module. -* -* This function enables the clock for FTF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! -* @brief Disable the clock for FTF module. -* -* This function disables the clock for FTF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! -* @brief Get the the clock gate state for FTF module. -* -* This function will get the clock gate state for FTF module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! -* @brief Enable the clock for ADC module. -* -* This function enables the clock for ADC module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! -* @brief Disable the clock for ADC module. -* -* This function disables the clock for ADC module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for ADC module. -* -* This function will get the clock gate state for ADC module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for CMP module. -* -* This function enables the clock for CMP module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp0); -} - -/*! -* @brief Disable the clock for CMP module. -* -* This function disables the clock for CMP module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp0); -} - -/*! -* @brief Get the the clock gate state for CMP module. -* -* This function will get the clock gate state for CMP module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp0); -} - -/*! -* @brief Enable the clock for VREF module. -* -* This function enables the clock for VREF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! -* @brief Disable the clock for VREF module. -* -* This function disables the clock for VREF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! -* @brief Get the the clock gate state for VREF module. -* -* This function will get the clock gate state for VREF module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! -* @brief Enable the clock for LPTIMER module. -* -* This function enables the clock for LPTIMER module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! -* @brief Disable the clock for LPTIMER module. -* -* This function disables the clock for LPTIMER module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! -* @brief Get the the clock gate state for LPTIMER module. -* -* This function will get the clock gate state for LPTIMER module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! -* @brief Enable the clock for RTC module. -* -* This function enables the clock for RTC module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! -* @brief Disable the clock for RTC module. -* -* This function disables the clock for RTC module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! -* @brief Get the the clock gate state for RTC module. -* -* This function will get the clock gate state for RTC module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! -* @brief Enable the clock for SPI module. -* -* This function enables the clock for SPI module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! -* @brief Disable the clock for SPI module. -* -* This function disables the clock for SPI module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for SPI module. -* -* This function will get the clock gate state for SPI module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for I2C module. -* -* This function enables the clock for I2C module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! -* @brief Disable the clock for I2C module. -* -* This function disables the clock for I2C module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for I2C module. -* -* This function will get the clock gate state for I2C module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for LPUART module. -* -* This function enables the clock for LPUART module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableLpuartClock(uint32_t instance); - -/*! -* @brief Disable the clock for LPUART module. -* -* This function disables the clock for LPUART module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableLpuartClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for LPUART module. -* -* This function will get the clock gate state for LPUART module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetLpuartGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for UART module. -* -* This function enables the clock for UART module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUart2); -} - -/*! -* @brief Disable the clock for UART module. -* -* This function disables the clock for UART module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUart2); -} - -/*! -* @brief Get the the clock gate state for UART module. -* -* This function will get the clock gate state for UART module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM,kSimClockGateUart2); -} - -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! -* @brief Enable the clock for FLEXIO module. -* -* This function enables the clock for FLEXIO module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableFlexioClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexio0); -} - -/*! -* @brief Disable the clock for FLEXIO module. -* -* This function disables the clock for FLEXIO module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableFlexioClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexio0); -} - -/*! -* @brief Get the clock gate state for FLEXIO module. -* -* This function will get the clock gate state for FLEXIO module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetFlexioGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM,kSimClockGateFlexio0); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for TPM module. - * - * This function enables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableTpmClock(uint32_t instance); - -/*! - * @brief Disable the clock for TPM module. - * - * This function disables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableTpmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for TPM module. - * - * This function will get the clock gate state for TPM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance); - -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the TPM external clock frequency(TPM_CLKx). - * - * This function sets the TPM external clock frequency (TPM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetTpmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < TPM_EXT_CLK_COUNT); - - g_tpmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - - -#endif /* __FSL_CLOCK_MKL17Z644__H__ */ -/******************************************************************************* -* EOF -******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL24Z4/fsl_clock_MKL24Z4.c b/KSDK_1.2.0/platform/system/src/clock/MKL24Z4/fsl_clock_MKL24Z4.c deleted file mode 100755 index ff253b4..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL24Z4/fsl_clock_MKL24Z4.c +++ /dev/null @@ -1,986 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" -#include "fsl_mcg_hal.h" -#include "fsl_clock_manager.h" -#include "fsl_os_abstraction.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; /* TPM_CLK */ -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - 0U, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFreq - * Description : Internal function to get the frequency by clock name - * This function will get/calculate the clock frequency based on clock name - * and current configuration of clock generator. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - - CLOCK_HAL_SetOutDiv(SIM, 2U, 0U, 0U, 5U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - - /*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the systen clock frequency. - * This function gets the systen clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - freq >>= 1U; /* divided by 2 for special divider */ - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return CLOCK_SYS_GetExternalRefClock32kFreq() >> 15U; - } - else - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCopFreq - * Description : Gets cop clock frequency. - * This function gets the cop clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCopFreq(uint32_t instance, clock_cop_src_t copSrc) -{ - if (kClockCopSrcLpoClk == copSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcFreq - * Description : Gets rtc clock frequency. - * This function gets rtc clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmfFreq - * Description : Gets the clock frequency for TPM module. - * This function gets the clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance) -{ - uint32_t freq; - clock_tpm_src_t src; - - src = CLOCK_HAL_GetTpmSrc(SIM, instance); - - switch(src) - { - case kClockTpmSrcPllFllSel: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTpmSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTpmSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmExternalFreq - * Description : Gets the external clock frequency for TPM module. - * This function gets the external clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance) -{ - sim_tpm_clk_sel_t src = CLOCK_SYS_GetTpmExternalSrc(instance); - - if (kSimTpmClkSel0 == src) - { - return g_tpmClkFreq[0]; - } - else - { - return g_tpmClkFreq[1]; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG moudle. - * - *END**************************************************************************/ -#if FSL_FEATURE_SOC_USB_COUNT -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - return freq; - } -} -#endif - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpifFreq - * Description : Gets the clock frequency for SPI module. - * This function gets the clock frequency for SPI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetBusClockFreq(); /* BUS CLOCK */ - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); /* SYSTEM CLOCK*/ - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cfFreq - * Description : Gets the clock frequency for I2C module. - * This function gets the clock frequency for I2C moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetBusClockFreq(); /* BUS CLOCK */ - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); /* SYSTEM CLOCK*/ - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLpsciFreq - * Description : Gets the clock frequency for LPSCI module. - * This function gets the clock frequency for LPSCI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpsciFreq(uint32_t instance) -{ - uint32_t freq; - clock_lpsci_src_t src; - - src = CLOCK_HAL_GetLpsciSrc(SIM, instance); - - switch(src) - { - case kClockLpsciSrcPllFllSel: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockLpsciSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpsciSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq = 0; - - switch (instance) - { - case 0: - case 1: - case 2: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - - - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -#if FSL_FEATURE_SOC_DAC_COUNT -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} -#endif - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Lpsci instance table. */ -static const sim_clock_gate_name_t lpsciGateTable[] = -{ - kSimClockGateLpsci0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableLpsciClock - * Description : Enable the clock for LPSCI module - * This function disable the clock for LPSCI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableLpsciClock(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - SIM_HAL_DisableClock(SIM, lpsciGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetLpsciGateCmd - * Description : Get the the clock gate state for LPSCI module - * This function will get the clock gate state for LPSCI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetLpsciGateCmd(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, lpsciGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableLpsciClock - * Description : Enable the clock for LPSCI module - * This function enables the clock for LPSCI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableLpsciClock(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - SIM_HAL_EnableClock(SIM, lpsciGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - (sim_clock_gate_name_t)(-1), - kSimClockGateUart1, - kSimClockGateUart2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t tpmGateTable[] = -{ - kSimClockGateTpm0, - kSimClockGateTpm1, - kSimClockGateTpm2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableTpmClock - * Description : Enable the clock for TPM module - * This function enables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_EnableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableTpmClock - * Description : Disable the clock for TPM module - * This function disables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_DisableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmGateCmd - * Description : Get the the clock gate state for TPM module - * This function will get the clock gate state for TPM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, tpmGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL24Z4/fsl_clock_MKL24Z4.h b/KSDK_1.2.0/platform/system/src/clock/MKL24Z4/fsl_clock_MKL24Z4.h deleted file mode 100644 index 6cd3a2e..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL24Z4/fsl_clock_MKL24Z4.h +++ /dev/null @@ -1,1115 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KL24Z4_H__) -#define __FSL_CLOCK_KL24Z4_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kl24z4 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief TPM external clock source count. */ -#define TPM_EXT_CLK_COUNT 2 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 - -/*! @brief TPM external clock frequency(TPM_CLK). */ -extern uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kl24z4_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance); - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the COP clock frequency. - * - * This function gets the COP clock frequency. - * - * @param instance module device instance - * @param copSrc COP clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetCopFreq(uint32_t instance, clock_cop_src_t copSrc); -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets TPM clock frequency. - * - * This function gets the TPM clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance); - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param instance IP instance. - * @param tpmSrc The value to set. - */ -static inline void CLOCK_SYS_SetTpmSrc(uint32_t instance, clock_tpm_src_t tpmSrc) -{ - CLOCK_HAL_SetTpmSrc(SIM, instance, tpmSrc); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_SYS_GetTpmSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTpmSrc(SIM, instance); -} - -/*! - * @brief Get the TPM external clock source frequency. - * - * This function gets the TPM external clock source frequency. - * - * @param instance IP instance. - * @return TPM external clock frequency. - */ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance); - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @param src TPM external clock source. - */ -static inline void CLOCK_SYS_SetTpmExternalSrc(uint32_t instance, sim_tpm_clk_sel_t src) -{ - SIM_HAL_SetTpmExternalClkPinSelMode(SIM, instance, src); -} - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @return setting Current TPM external clock source. - */ -static inline sim_tpm_clk_sel_t CLOCK_SYS_GetTpmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ - #if FSL_FEATURE_SOC_USB_COUNT -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @param usbfsSrc The value to set. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} -#endif - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance); - - /*! - * @brief Gets the clock frequency for LPSCI module. - * - * This function gets the clock frequency for LPSCI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpsciFreq(uint32_t instance); - -/*! - * @brief Set the LPSCI clock source selection. - * - * This function sets the LPSCI clock source selection. - * - * @param instance IP instance. - * @param lpsciSrc The value to set. - */ -static inline void CLOCK_SYS_SetLpsciSrc(uint32_t instance, clock_lpsci_src_t lpsciSrc) -{ - CLOCK_HAL_SetLpsciSrc(SIM, instance, lpsciSrc); -} - -/*! - * @brief Get the LPSCI clock source selection. - * - * This function gets the LPSCI clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_lpsci_src_t CLOCK_SYS_GetLpsciSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpsciSrc(SIM, instance); -} - -/*! - * @brief Get the UART clock frequency. - * - * This function gets the UART clock frequency. - * - * @param instance IP instance. - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -#if FSL_FEATURE_SOC_DAC_COUNT -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); -#endif - -/*! - * @brief Enable the clock for TPM module. - * - * This function enables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableTpmClock(uint32_t instance); - -/*! - * @brief Disable the clock for TPM module. - * - * This function disables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableTpmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for TPM module. - * - * This function will get the clock gate state for TPM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for TSI module. - * - * This function enables the clock for TSI module. - * @param instance module device instance - */ -#if FSL_FEATURE_SOC_TSI_COUNT -static inline void CLOCK_SYS_EnableTsiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Disable the clock for TSI module. - * - * This function disables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTsiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Get the the clock gate state for TSI module. - * - * This function will get the clock gate state for TSI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTsiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTsi0); -} -#endif - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ - #if FSL_FEATURE_SOC_USB_COUNT -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} -#endif - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for LPSCI module. - * - * This function enables the clock for LPSCI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableLpsciClock(uint32_t instance); - -/*! - * @brief Disable the clock for LPSCI module. - * - * This function disables the clock for LPSCI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableLpsciClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for LPSCI module. - * - * This function will get the clock gate state for LPSCI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetLpsciGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the TPM external clock frequency(TPM_CLKx). - * - * This function sets the TPM external clock frequency (TPM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetTpmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < TPM_EXT_CLK_COUNT); - - g_tpmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KL24Z4_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL25Z4/fsl_clock_MKL25Z4.c b/KSDK_1.2.0/platform/system/src/clock/MKL25Z4/fsl_clock_MKL25Z4.c deleted file mode 100755 index ff253b4..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL25Z4/fsl_clock_MKL25Z4.c +++ /dev/null @@ -1,986 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" -#include "fsl_mcg_hal.h" -#include "fsl_clock_manager.h" -#include "fsl_os_abstraction.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; /* TPM_CLK */ -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - 0U, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFreq - * Description : Internal function to get the frequency by clock name - * This function will get/calculate the clock frequency based on clock name - * and current configuration of clock generator. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - - CLOCK_HAL_SetOutDiv(SIM, 2U, 0U, 0U, 5U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - - /*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the systen clock frequency. - * This function gets the systen clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - freq >>= 1U; /* divided by 2 for special divider */ - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return CLOCK_SYS_GetExternalRefClock32kFreq() >> 15U; - } - else - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCopFreq - * Description : Gets cop clock frequency. - * This function gets the cop clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCopFreq(uint32_t instance, clock_cop_src_t copSrc) -{ - if (kClockCopSrcLpoClk == copSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcFreq - * Description : Gets rtc clock frequency. - * This function gets rtc clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmfFreq - * Description : Gets the clock frequency for TPM module. - * This function gets the clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance) -{ - uint32_t freq; - clock_tpm_src_t src; - - src = CLOCK_HAL_GetTpmSrc(SIM, instance); - - switch(src) - { - case kClockTpmSrcPllFllSel: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTpmSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTpmSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmExternalFreq - * Description : Gets the external clock frequency for TPM module. - * This function gets the external clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance) -{ - sim_tpm_clk_sel_t src = CLOCK_SYS_GetTpmExternalSrc(instance); - - if (kSimTpmClkSel0 == src) - { - return g_tpmClkFreq[0]; - } - else - { - return g_tpmClkFreq[1]; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG moudle. - * - *END**************************************************************************/ -#if FSL_FEATURE_SOC_USB_COUNT -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - return freq; - } -} -#endif - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpifFreq - * Description : Gets the clock frequency for SPI module. - * This function gets the clock frequency for SPI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetBusClockFreq(); /* BUS CLOCK */ - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); /* SYSTEM CLOCK*/ - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cfFreq - * Description : Gets the clock frequency for I2C module. - * This function gets the clock frequency for I2C moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetBusClockFreq(); /* BUS CLOCK */ - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); /* SYSTEM CLOCK*/ - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLpsciFreq - * Description : Gets the clock frequency for LPSCI module. - * This function gets the clock frequency for LPSCI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpsciFreq(uint32_t instance) -{ - uint32_t freq; - clock_lpsci_src_t src; - - src = CLOCK_HAL_GetLpsciSrc(SIM, instance); - - switch(src) - { - case kClockLpsciSrcPllFllSel: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockLpsciSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpsciSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq = 0; - - switch (instance) - { - case 0: - case 1: - case 2: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - - - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -#if FSL_FEATURE_SOC_DAC_COUNT -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} -#endif - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Lpsci instance table. */ -static const sim_clock_gate_name_t lpsciGateTable[] = -{ - kSimClockGateLpsci0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableLpsciClock - * Description : Enable the clock for LPSCI module - * This function disable the clock for LPSCI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableLpsciClock(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - SIM_HAL_DisableClock(SIM, lpsciGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetLpsciGateCmd - * Description : Get the the clock gate state for LPSCI module - * This function will get the clock gate state for LPSCI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetLpsciGateCmd(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, lpsciGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableLpsciClock - * Description : Enable the clock for LPSCI module - * This function enables the clock for LPSCI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableLpsciClock(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - SIM_HAL_EnableClock(SIM, lpsciGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - (sim_clock_gate_name_t)(-1), - kSimClockGateUart1, - kSimClockGateUart2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t tpmGateTable[] = -{ - kSimClockGateTpm0, - kSimClockGateTpm1, - kSimClockGateTpm2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableTpmClock - * Description : Enable the clock for TPM module - * This function enables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_EnableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableTpmClock - * Description : Disable the clock for TPM module - * This function disables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_DisableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmGateCmd - * Description : Get the the clock gate state for TPM module - * This function will get the clock gate state for TPM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, tpmGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL25Z4/fsl_clock_MKL25Z4.h b/KSDK_1.2.0/platform/system/src/clock/MKL25Z4/fsl_clock_MKL25Z4.h deleted file mode 100644 index 734bd8d..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL25Z4/fsl_clock_MKL25Z4.h +++ /dev/null @@ -1,1115 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KL25Z4_H__) -#define __FSL_CLOCK_KL25Z4_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kl25z4 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief TPM external clock source count. */ -#define TPM_EXT_CLK_COUNT 2 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 - -/*! @brief TPM external clock frequency(TPM_CLK). */ -extern uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kl25z4_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance); - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the COP clock frequency. - * - * This function gets the COP clock frequency. - * - * @param instance module device instance - * @param copSrc COP clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetCopFreq(uint32_t instance, clock_cop_src_t copSrc); -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets TPM clock frequency. - * - * This function gets the TPM clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance); - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param instance IP instance. - * @param tpmSrc The value to set. - */ -static inline void CLOCK_SYS_SetTpmSrc(uint32_t instance, clock_tpm_src_t tpmSrc) -{ - CLOCK_HAL_SetTpmSrc(SIM, instance, tpmSrc); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_SYS_GetTpmSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTpmSrc(SIM, instance); -} - -/*! - * @brief Get the TPM external clock source frequency. - * - * This function gets the TPM external clock source frequency. - * - * @param instance IP instance. - * @return TPM external clock frequency. - */ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance); - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @param src TPM external clock source. - */ -static inline void CLOCK_SYS_SetTpmExternalSrc(uint32_t instance, sim_tpm_clk_sel_t src) -{ - SIM_HAL_SetTpmExternalClkPinSelMode(SIM, instance, src); -} - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @return setting Current TPM external clock source. - */ -static inline sim_tpm_clk_sel_t CLOCK_SYS_GetTpmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ - #if FSL_FEATURE_SOC_USB_COUNT -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @param usbfsSrc The value to set. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} -#endif - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance); - - /*! - * @brief Gets the clock frequency for LPSCI module. - * - * This function gets the clock frequency for LPSCI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpsciFreq(uint32_t instance); - -/*! - * @brief Set the LPSCI clock source selection. - * - * This function sets the LPSCI clock source selection. - * - * @param instance IP instance. - * @param lpsciSrc The value to set. - */ -static inline void CLOCK_SYS_SetLpsciSrc(uint32_t instance, clock_lpsci_src_t lpsciSrc) -{ - CLOCK_HAL_SetLpsciSrc(SIM, instance, lpsciSrc); -} - -/*! - * @brief Get the LPSCI clock source selection. - * - * This function gets the LPSCI clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_lpsci_src_t CLOCK_SYS_GetLpsciSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpsciSrc(SIM, instance); -} - -/*! - * @brief Get the UART clock frequency. - * - * This function gets the UART clock frequency. - * - * @param instance IP instance. - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -#if FSL_FEATURE_SOC_DAC_COUNT -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); -#endif - -/*! - * @brief Enable the clock for TPM module. - * - * This function enables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableTpmClock(uint32_t instance); - -/*! - * @brief Disable the clock for TPM module. - * - * This function disables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableTpmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for TPM module. - * - * This function will get the clock gate state for TPM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for TSI module. - * - * This function enables the clock for TSI module. - * @param instance module device instance - */ -#if FSL_FEATURE_SOC_TSI_COUNT -static inline void CLOCK_SYS_EnableTsiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Disable the clock for TSI module. - * - * This function disables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTsiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Get the the clock gate state for TSI module. - * - * This function will get the clock gate state for TSI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTsiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTsi0); -} -#endif - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ - #if FSL_FEATURE_SOC_USB_COUNT -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} -#endif - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for LPSCI module. - * - * This function enables the clock for LPSCI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableLpsciClock(uint32_t instance); - -/*! - * @brief Disable the clock for LPSCI module. - * - * This function disables the clock for LPSCI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableLpsciClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for LPSCI module. - * - * This function will get the clock gate state for LPSCI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetLpsciGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the TPM external clock frequency(TPM_CLKx). - * - * This function sets the TPM external clock frequency (TPM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetTpmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < TPM_EXT_CLK_COUNT); - - g_tpmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KL25Z4_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL26Z4/fsl_clock_MKL26Z4.c b/KSDK_1.2.0/platform/system/src/clock/MKL26Z4/fsl_clock_MKL26Z4.c deleted file mode 100755 index 71d7a5b..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL26Z4/fsl_clock_MKL26Z4.c +++ /dev/null @@ -1,1012 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" -#include "fsl_mcg_hal.h" -#include "fsl_clock_manager.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; /* TPM_CLK */ -#if FSL_FEATURE_SOC_USB_COUNT -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -#endif - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - 0U, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - - CLOCK_HAL_SetOutDiv(SIM, 2U, 0U, 0U, 5U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - - /*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the systen clock frequency. - * This function gets the systen clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - freq >>= 1U; /* divided by 2 for special divider */ - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return CLOCK_SYS_GetExternalRefClock32kFreq() >> 15U; - } - else - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCopFreq - * Description : Gets COP clock frequency. - * This function gets the COP clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCopFreq(uint32_t instance, clock_cop_src_t copSrc) -{ - if (kClockCopSrcLpoClk == copSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcFreq - * Description : Gets rtc clock frequency. - * This function gets rtc clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmfFreq - * Description : Gets the clock frequency for TPM module. - * This function gets the clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance) -{ - uint32_t freq; - clock_tpm_src_t src; - - src = CLOCK_HAL_GetTpmSrc(SIM, instance); - - switch(src) - { - case kClockTpmSrcPllFllSel: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTpmSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTpmSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmExternalFreq - * Description : Gets the external clock frequency for TPM module. - * This function gets the external clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance) -{ - sim_tpm_clk_sel_t src = CLOCK_SYS_GetTpmExternalSrc(instance); - - if (kSimTpmClkSel0 == src) - { - return g_tpmClkFreq[0]; - } - else - { - return g_tpmClkFreq[1]; - } -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - return freq; - } -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpifFreq - * Description : Gets the clock frequency for SPI module. - * This function gets the clock frequency for SPI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetBusClockFreq(); /* BUS CLOCK */ - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); /* SYSTEM CLOCK*/ - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cfFreq - * Description : Gets the clock frequency for I2C module. - * This function gets the clock frequency for I2C moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetBusClockFreq(); /* BUS CLOCK */ - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); /* SYSTEM CLOCK*/ - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLpsciFreq - * Description : Gets the clock frequency for LPSCI module. - * This function gets the clock frequency for LPSCI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpsciFreq(uint32_t instance) -{ - uint32_t freq; - clock_lpsci_src_t src; - - src = CLOCK_HAL_GetLpsciSrc(SIM, instance); - - switch(src) - { - case kClockLpsciSrcPllFllSel: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockLpsciSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpsciSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq = 0; - - switch (instance) - { - case 0: - case 1: - case 2: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Lpsci instance table. */ -static const sim_clock_gate_name_t lpsciGateTable[] = -{ - kSimClockGateLpsci0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableLpsciClock - * Description : Enable the clock for LPSCI module - * This function disable the clock for LPSCI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableLpsciClock(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - SIM_HAL_DisableClock(SIM, lpsciGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetLpsciGateCmd - * Description : Get the the clock gate state for LPSCI module - * This function will get the clock gate state for LPSCI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetLpsciGateCmd(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, lpsciGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableLpsciClock - * Description : Enable the clock for LPSCI module - * This function enables the clock for LPSCI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableLpsciClock(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - SIM_HAL_EnableClock(SIM, lpsciGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - (sim_clock_gate_name_t)(-1), - kSimClockGateUart1, - kSimClockGateUart2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t tpmGateTable[] = -{ - kSimClockGateTpm0, - kSimClockGateTpm1, - kSimClockGateTpm2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableTpmClock - * Description : Enable the clock for TPM module - * This function enables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_EnableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableTpmClock - * Description : Disable the clock for TPM module - * This function disables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_DisableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmGateCmd - * Description : Get the the clock gate state for TPM module - * This function will get the clock gate state for TPM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, tpmGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL26Z4/fsl_clock_MKL26Z4.h b/KSDK_1.2.0/platform/system/src/clock/MKL26Z4/fsl_clock_MKL26Z4.h deleted file mode 100644 index 69fa4d6..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL26Z4/fsl_clock_MKL26Z4.h +++ /dev/null @@ -1,1237 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KL26Z4_H__) -#define __FSL_CLOCK_KL26Z4_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kl26z4 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief TPM external clock source count. */ -#define TPM_EXT_CLK_COUNT 2 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 - -/*! @brief TPM external clock frequency(TPM_CLK). */ -extern uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -#endif - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kl26z4_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the COP clock frequency. - * - * This function gets the COP clock frequency. - * - * @param instance module device instance - * @param copSrc COP clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetCopFreq(uint32_t instance, clock_cop_src_t copSrc); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets TPM clock frequency. - * - * This function gets the TPM clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance); - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param instance IP instance. - * @param tpmSrc The value to set. - */ -static inline void CLOCK_SYS_SetTpmSrc(uint32_t instance, clock_tpm_src_t tpmSrc) -{ - CLOCK_HAL_SetTpmSrc(SIM, instance, tpmSrc); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_SYS_GetTpmSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTpmSrc(SIM, instance); -} - -/*! - * @brief Get the TPM external clock source frequency. - * - * This function gets the TPM external clock source frequency. - * - * @param instance IP instance. - * @return TPM external clock frequency. - */ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance); - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @param src TPM external clock source. - */ -static inline void CLOCK_SYS_SetTpmExternalSrc(uint32_t instance, sim_tpm_clk_sel_t src) -{ - SIM_HAL_SetTpmExternalClkPinSelMode(SIM, instance, src); -} - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @return setting Current TPM external clock source. - */ -static inline sim_tpm_clk_sel_t CLOCK_SYS_GetTpmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @param usbfsSrc The value to set. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance); - - /*! - * @brief Gets the clock frequency for LPSCI module. - * - * This function gets the clock frequency for LPSCI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpsciFreq(uint32_t instance); - -/*! - * @brief Set the LPSCI clock source selection. - * - * This function sets the LPSCI clock source selection. - * - * @param instance IP instance. - * @param lpsciSrc The value to set. - */ -static inline void CLOCK_SYS_SetLpsciSrc(uint32_t instance, clock_lpsci_src_t lpsciSrc) -{ - CLOCK_HAL_SetLpsciSrc(SIM, instance, lpsciSrc); -} - -/*! - * @brief Get the LPSCI clock source selection. - * - * This function gets the LPSCI clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_lpsci_src_t CLOCK_SYS_GetLpsciSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpsciSrc(SIM, instance); -} - -/*! - * @brief Get the UART clock frequency. - * - * This function gets the UART clock frequency. - * - * @param instance IP instance. - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_LCD_COUNT -/*! - * @brief Enable the clock for SLCD module. - * - * This function enables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSlcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Disable the clock for SLCD module. - * - * This function disables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSlcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Get the the clock gate state for SLCD module. - * - * This function will get the clock gate state for SLCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSlcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Gets the frequency for SLCD default clock. - * - * This function gets the frequency for SLCD default clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdDefaultFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets the frequency for SLCD alternate clock. - * - * This function gets the frequency for SLCD alternate clock (ALTSOURCE = 0). - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAltFreq(uint32_t instance) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the frequency for SLCD alternate 2 clock. - * - * This function gets the frequency for SLCD alternate 2 clock (ALTSOURCE = 1). - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAlt2Freq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} -#endif// FSL_FEATURE_SOC_LCD_COUNT - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for TPM module. - * - * This function enables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableTpmClock(uint32_t instance); - -/*! - * @brief Disable the clock for TPM module. - * - * This function disables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableTpmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for TPM module. - * - * This function will get the clock gate state for TPM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for TSI module. - * - * This function enables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTsiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Disable the clock for TSI module. - * - * This function disables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTsiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Get the the clock gate state for TSI module. - * - * This function will get the clock gate state for TSI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTsiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTsi0); -} - - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for LPSCI module. - * - * This function enables the clock for LPSCI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableLpsciClock(uint32_t instance); - -/*! - * @brief Disable the clock for LPSCI module. - * - * This function disables the clock for LPSCI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableLpsciClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for LPSCI module. - * - * This function will get the clock gate state for LPSCI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetLpsciGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Set the TPM external clock frequency(TPM_CLKx). - * - * This function sets the TPM external clock frequency (TPM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetTpmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < TPM_EXT_CLK_COUNT); - - g_tpmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KL26Z4_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL27Z644/fsl_clock_MKL27Z644.c b/KSDK_1.2.0/platform/system/src/clock/MKL27Z644/fsl_clock_MKL27Z644.c deleted file mode 100755 index d204e3a..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL27Z644/fsl_clock_MKL27Z644.c +++ /dev/null @@ -1,804 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcglite_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* -* README: -* This file should provide these APIs: -* 1. APIs to get the frequency of output clocks in Reference Manual -> -* Chapter Clock Distribution -> Figure Clocking diagram. -* 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution -* -> Module clocks. -*/ - -/******************************************************************************* -* Definitions -******************************************************************************/ -uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; /* TPM_CLK */ -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ - -/******************************************************************************* -* Code -******************************************************************************/ - - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - 0U, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 1U, 0U, 0U, 7U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgliteMode(&config->mcgliteConfig); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kIrc48mClock: - *frequency = kMcgliteConst48M; - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetCoreClockFreq -* Description : Gets the core clock frequency. -* This function gets the core clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetSystemClockFreq -* Description : Gets the systen clock frequency. -* This function gets the systen clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetBusClockFreq -* Description : Gets the bus clock frequency. -* This function gets the bus clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetFlashClockFreq -* Description : Gets the flash clock frequency. -* This function gets the flash clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetRtcOutFreq -* Description : Gets the RTC_CLKOUT frequency. -* This function gets RTC_CLKOUT clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return 1U; - } - else - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetExternalRefClockFreq -* Description : Gets the ERCLK32K clock frequency. -* This function gets the external reference (ERCLK32K) clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq -* Description : Gets OSC0ERCLK. -* This function gets the OSC0 external reference frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetCopFreq -* Description : Gets the clock frequency for COP module. -* This function gets the clock frequency for COP moudle. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetCopFreq(void) -{ - clock_cop_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetCopSrc(SIM); - - switch (src) - { - case kClockCopSrcLpoClk: - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockCopSrcMcgIrClk: - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockCopSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockCopSrcBusClk: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetTpmFreq -* Description : Gets the clock frequency for TPM module. -* This function gets the clock frequency for TPM moudle. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance) -{ - - clock_tpm_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetTpmSrc(SIM, instance); - - switch (src) - { - case kClockTpmSrcIrc48M: /* IRC48M */ - freq = kMcgliteConst48M; - break; - case kClockTpmSrcOsc0erClk: /* OSCER clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTpmSrcMcgIrClk: /* MCGIR clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetLpuartFreq -* Description : Gets the clock frequency for LPUART module. -* This function gets the clock frequency for LPUART moudle. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance) -{ - clock_lpuart_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetLpuartSrc(SIM, instance); - - switch (src) - { - case kClockLpuartSrcIrc48M: /* IRC48M */ - freq = kMcgliteConst48M; - break; - case kClockLpuartSrcOsc0erClk: /* OSCER clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpuartSrcMcgIrClk: /* MCGIR clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetTpmExternalFreq -* Description : Gets Tpm external clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance) -{ - sim_tpm_clk_sel_t sel = SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); - - if (kSimTpmClkSel0 == sel) - { - return g_tpmClkFreq[0]; - } - else - { - return g_tpmClkFreq[1]; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - clock_usbfs_src_t src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; - } - else - { - return kMcgliteConst48M; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexioFreq - * Description : Gets the clock frequency for FLEXIO. - * This function gets the clock frequency for FLEXIO. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexioFreq(uint32_t instance) -{ - uint32_t freq; - clock_flexio_src_t src = CLOCK_HAL_GetFlexioSrc(SIM, instance); - - switch (src) - { - case kClockFlexioSrcIrc48M: - freq = kMcgliteConst48M; - break; - case kClockFlexioSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockFlexioSrcMcgIrClk: - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiFreq - * Description : Gets the clock frequency for SPI. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - assert(instance < SPI_INSTANCE_COUNT); - - if (0U == instance) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetSystemClockFreq(); - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnablePortClock -* Description : Enable the clock for PORT module -* This function enables the clock for PORT moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisablePortClock -* Description : Disable the clock for PORT module -* This function disables the clock for PORT moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetPortGateCmd -* Description : Get the the clock gate state for PORT module -* This function will get the clock gate state for PORT moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableAdcClock -* Description : Enable the clock for ADC module -* This function enables the clock for ADC moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableAdcClock -* Description : Disable the clock for ADC module -* This function disables the clock for ADC moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetAdcGateCmd -* Description : Get the the clock gate state for ADC module -* This function will get the clock gate state for ADC moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableSpiClock -* Description : Enable the clock for SPI module -* This function enables the clock for SPI moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableSpiClock -* Description : Disable the clock for SPI module -* This function disables the clock for SPI moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetSpiGateCmd -* Description : Get the the clock gate state for SPI module -* This function will get the clock gate state for SPI moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableI2cClock -* Description : Enable the clock for I2C module -* This function enables the clock for I2C moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableI2cClock -* Description : Disable the clock for I2C module -* This function disables the clock for I2C moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetI2cGateCmd -* Description : Get the the clock gate state for I2C module -* This function will get the clock gate state for I2C moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Lpuart instance table. */ -static const sim_clock_gate_name_t lpuartGateTable[] = -{ - kSimClockGateLpuart0, - kSimClockGateLpuart1 -}; - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_EnableLpuartClock -* Description : Enable the clock for UART module -* This function enables the clock for UART moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableLpuartClock(uint32_t instance) -{ - assert(instance < sizeof(lpuartGateTable)/sizeof(lpuartGateTable[0])); - - SIM_HAL_EnableClock(SIM, lpuartGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_DisableLpuartClock -* Description : Disable the clock for UART module -* This function enables the clock for UART moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableLpuartClock(uint32_t instance) -{ - assert(instance < sizeof(lpuartGateTable)/sizeof(lpuartGateTable[0])); - - SIM_HAL_DisableClock(SIM, lpuartGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_GetLpuartGateCmd -* Description : Get the the clock gate state for UART module -* This function will get the clock gate state for UART moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetLpuartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(lpuartGateTable)/sizeof(lpuartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, lpuartGateTable[instance]); -} - -/* TPM instance table. */ -static const sim_clock_gate_name_t tpmGateTable[] = -{ - kSimClockGateTpm0, - kSimClockGateTpm1, - kSimClockGateTpm2, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableTpmClock -* Description : Enable the clock for TPM module -* This function enables the clock for TPM moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_EnableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableTpmClock -* Description : Disable the clock for TPM module -* This function disables the clock for TPM moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_DisableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetTpmGateCmd -* Description : Get the the clock gate state for TPM module -* This function will get the clock gate state for TPM moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, tpmGateTable[instance]); -} - -/******************************************************************************* -* EOF -******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL27Z644/fsl_clock_MKL27Z644.h b/KSDK_1.2.0/platform/system/src/clock/MKL27Z644/fsl_clock_MKL27Z644.h deleted file mode 100644 index 894244c..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL27Z644/fsl_clock_MKL27Z644.h +++ /dev/null @@ -1,1193 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#if !defined(__FSL_CLOCK_MKL27Z644_H__) -#define __FSL_CLOCK_MKL27Z644_H__ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcglite_hal.h" -#include "fsl_mcglite_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kl27z644 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* -* Definitions -******************************************************************************/ -/*! @brief TPM external clock source count. */ -#define TPM_EXT_CLK_COUNT 2 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 - -/*! @brief TPM external clock frequency(TPM_CLK). */ -extern uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kl27z644_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* -* API -******************************************************************************/ -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! -* @brief Get internal reference clock frequency. -* -* This function gets the internal reference clock frequency. -* -* @return Current clock frequency. -*/ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! -* @brief Gets the OSC0ERCLK frequency. -* -* This function gets the OSC0 external reference frequency. -* -* @return Current frequency. -*/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! -* @brief Gets RTC_CLKOUT frequency. -* -* This function gets the frequency of RTC_CLKOUT. -* -* @return Current frequency. -*/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! -* @brief Gets RTC_CLKOUT source. -* -* This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. -* -* @return Current source. -*/ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! -* @brief Gets RTC_CLKOUT source. -* -* This function sets the source of RTC_CLKOUT. -* -* @param src RTC_CLKOUT source to set. -*/ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - - /*! - * @brief Gets rtc clock frequency. - * - * This function gets the rtc clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets COP clock frequency. - * - * This function gets the COP clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetCopFreq(void); - -/*! - * @brief Set the COP clock source selection. - * - * This function sets the COP clock source selection. - * - * @param copSrc The value to set. - */ -static inline void CLOCK_SYS_SetCopSrc(clock_cop_src_t copSrc) -{ - CLOCK_HAL_SetCopSrc(SIM, copSrc); -} - -/*! - * @brief Get the COP clock source selection. - * - * This function gets the COP clock source selection. - * - * @return Current selection. - */ -static inline clock_cop_src_t CLOCK_SYS_GetCopSrc(void) -{ - return CLOCK_HAL_GetCopSrc(SIM); -} - -/*! - * @brief Gets TPM clock frequency. - * - * This function gets the TPM clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance); - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param instance IP instance. - * @param tpmSrc The value to set. - */ -static inline void CLOCK_SYS_SetTpmSrc(uint32_t instance, clock_tpm_src_t tpmSrc) -{ - CLOCK_HAL_SetTpmSrc(SIM, instance, tpmSrc); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_SYS_GetTpmSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTpmSrc(SIM, instance); -} - -/*! - * @brief Get the TPM external clock source frequency. - * - * This function gets the TPM external clock source frequency. - * - * @param instance IP instance. - * @return TPM external clock frequency. - */ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance); - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @param src TPM external clock source. - */ -static inline void CLOCK_SYS_SetTpmExternalSrc(uint32_t instance, sim_tpm_clk_sel_t src) -{ - SIM_HAL_SetTpmExternalClkPinSelMode(SIM, instance, src); -} - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @return setting Current TPM external clock source. - */ -static inline sim_tpm_clk_sel_t CLOCK_SYS_GetTpmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @param usbfsSrc The value to set. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Gets the clock source for LPUART module - * - * This function gets the clock source for LPUART module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_lpuart_src_t CLOCK_SYS_GetLpuartSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpuartSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for LPUART module - * - * This function sets the clock source for LPUART module. - * @param instance module device instance - * @param lpuartSrc Clock source. - */ -static inline void CLOCK_SYS_SetLpuartSrc(uint32_t instance, clock_lpuart_src_t lpuartSrc) -{ - CLOCK_HAL_SetLpuartSrc(SIM, instance, lpuartSrc); -} - -/*! - * @brief Gets the clock frequency for LPUART module - * - * This function gets the clock frequency for LPUART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance); - -/*! - * @brief Gets FLEXIO clock frequency. - * - * This function gets the FLEXIO clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexioFreq(uint32_t instance); - -/*! - * @brief Set the FLEXIO clock source selection. - * - * This function sets the FLEXIO clock source selection. - * - * @param instance IP instance. - * @param flexioSrc The value to set. - */ -static inline void CLOCK_SYS_SetFlexioSrc(uint32_t instance, clock_flexio_src_t flexioSrc) -{ - CLOCK_HAL_SetFlexioSrc(SIM, instance, flexioSrc); -} - -/*! - * @brief Get the FLEXIO clock source selection. - * - * This function gets the FLEXIO clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_flexio_src_t CLOCK_SYS_GetFlexioSrc(uint32_t instance) -{ - return CLOCK_HAL_GetFlexioSrc(SIM, instance); -} - -/*! -* @brief Gets the clock frequency for FTF module. (Flash Memory) -* -* This function gets the clock frequency for FTF module. (Flash Memory) -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets the clock frequency for CMP module. -* -* This function gets the clock frequency for CMP module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets the clock frequency for VREF module. -* -* This function gets the clock frequency for VREF module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets the clock frequency for SPI module -* -* This function gets the clock frequency for SPI module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance); - -/*! -* @brief Gets the clock frequency for I2C module -* -* This function gets the clock frequency for I2C module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets ADC alternate clock frequency. -* -* This function gets the ADC alternate clock frequency. -* -* @param instance module device instance -* @return freq Current frequency. -*/ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! -* @brief Gets the clock frequency for UART module -* -* This function gets the clock frequency for UART module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Enable the clock for PORT module. -* -* This function enables the clock for PORT module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! -* @brief Disable the clock for PORT module. -* -* This function disables the clock for PORT module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for PORT module. -* -* This function will get the clock gate state for PORT module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for FTF module. -* -* This function enables the clock for FTF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! -* @brief Disable the clock for FTF module. -* -* This function disables the clock for FTF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! -* @brief Get the the clock gate state for FTF module. -* -* This function will get the clock gate state for FTF module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! -* @brief Enable the clock for ADC module. -* -* This function enables the clock for ADC module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! -* @brief Disable the clock for ADC module. -* -* This function disables the clock for ADC module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for ADC module. -* -* This function will get the clock gate state for ADC module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for CMP module. -* -* This function enables the clock for CMP module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp0); -} - -/*! -* @brief Disable the clock for CMP module. -* -* This function disables the clock for CMP module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp0); -} - -/*! -* @brief Get the the clock gate state for CMP module. -* -* This function will get the clock gate state for CMP module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp0); -} - -/*! -* @brief Enable the clock for VREF module. -* -* This function enables the clock for VREF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! -* @brief Disable the clock for VREF module. -* -* This function disables the clock for VREF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! -* @brief Get the the clock gate state for VREF module. -* -* This function will get the clock gate state for VREF module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! -* @brief Enable the clock for LPTIMER module. -* -* This function enables the clock for LPTIMER module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! -* @brief Disable the clock for LPTIMER module. -* -* This function disables the clock for LPTIMER module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! -* @brief Get the the clock gate state for LPTIMER module. -* -* This function will get the clock gate state for LPTIMER module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! -* @brief Enable the clock for RTC module. -* -* This function enables the clock for RTC module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! -* @brief Disable the clock for RTC module. -* -* This function disables the clock for RTC module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! -* @brief Get the the clock gate state for RTC module. -* -* This function will get the clock gate state for RTC module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! -* @brief Enable the clock for SPI module. -* -* This function enables the clock for SPI module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! -* @brief Disable the clock for SPI module. -* -* This function disables the clock for SPI module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for SPI module. -* -* This function will get the clock gate state for SPI module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for I2C module. -* -* This function enables the clock for I2C module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! -* @brief Disable the clock for I2C module. -* -* This function disables the clock for I2C module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for I2C module. -* -* This function will get the clock gate state for I2C module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for LPUART module. -* -* This function enables the clock for LPUART module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableLpuartClock(uint32_t instance); - -/*! -* @brief Disable the clock for LPUART module. -* -* This function disables the clock for LPUART module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableLpuartClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for LPUART module. -* -* This function will get the clock gate state for LPUART module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetLpuartGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for UART module. -* -* This function enables the clock for UART module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUart2); -} - -/*! -* @brief Disable the clock for UART module. -* -* This function disables the clock for UART module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUart2); -} - -/*! -* @brief Get the the clock gate state for UART module. -* -* This function will get the clock gate state for UART module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM,kSimClockGateUart2); -} - -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! -* @brief Enable the clock for FLEXIO module. -* -* This function enables the clock for FLEXIO module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableFlexioClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexio0); -} - -/*! -* @brief Disable the clock for FLEXIO module. -* -* This function disables the clock for FLEXIO module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableFlexioClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexio0); -} - -/*! -* @brief Get the clock gate state for FLEXIO module. -* -* This function will get the clock gate state for FLEXIO module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetFlexioGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM,kSimClockGateFlexio0); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for TPM module. - * - * This function enables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableTpmClock(uint32_t instance); - -/*! - * @brief Disable the clock for TPM module. - * - * This function disables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableTpmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for TPM module. - * - * This function will get the clock gate state for TPM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance); - -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} - -/*! - * @brief Set the TPM external clock frequency(TPM_CLKx). - * - * This function sets the TPM external clock frequency (TPM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetTpmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < TPM_EXT_CLK_COUNT); - - g_tpmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - - -#endif /* __FSL_CLOCK_MKL27Z644__H__ */ -/******************************************************************************* -* EOF -******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL33Z4/fsl_clock_MKL33Z4.c b/KSDK_1.2.0/platform/system/src/clock/MKL33Z4/fsl_clock_MKL33Z4.c deleted file mode 100755 index d74eea3..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL33Z4/fsl_clock_MKL33Z4.c +++ /dev/null @@ -1,840 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcglite_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* -* README: -* This file should provide these APIs: -* 1. APIs to get the frequency of output clocks in Reference Manual -> -* Chapter Clock Distribution -> Figure Clocking diagram. -* 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution -* -> Module clocks. -*/ - -/******************************************************************************* -* Definitions -******************************************************************************/ -uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; /* TPM_CLK */ -#if FSL_FEATURE_SOC_USB_COUNT -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -#endif - -/******************************************************************************* -* Code -******************************************************************************/ - - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - 0U, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 1U, 0U, 0U, 7U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgliteMode(&config->mcgliteConfig); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kIrc48mClock: - *frequency = kMcgliteConst48M; - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetCoreClockFreq -* Description : Gets the core clock frequency. -* This function gets the core clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetSystemClockFreq -* Description : Gets the systen clock frequency. -* This function gets the systen clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetBusClockFreq -* Description : Gets the bus clock frequency. -* This function gets the bus clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetFlashClockFreq -* Description : Gets the flash clock frequency. -* This function gets the flash clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetRtcOutFreq -* Description : Gets the RTC_CLKOUT frequency. -* This function gets RTC_CLKOUT clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return 1U; - } - else - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetExternalRefClockFreq -* Description : Gets the ERCLK32K clock frequency. -* This function gets the external reference (ERCLK32K) clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq -* Description : Gets OSC0ERCLK. -* This function gets the OSC0 external reference frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetCopFreq -* Description : Gets the clock frequency for COP module. -* This function gets the clock frequency for COP moudle. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetCopFreq(void) -{ - clock_cop_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetCopSrc(SIM); - - switch (src) - { - case kClockCopSrcLpoClk: - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockCopSrcMcgIrClk: - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockCopSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockCopSrcBusClk: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetTpmFreq -* Description : Gets the clock frequency for TPM module. -* This function gets the clock frequency for TPM moudle. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance) -{ - - clock_tpm_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetTpmSrc(SIM, instance); - - switch (src) - { - case kClockTpmSrcIrc48M: /* IRC48M */ - freq = kMcgliteConst48M; - break; - case kClockTpmSrcOsc0erClk: /* OSCER clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTpmSrcMcgIrClk: /* MCGIR clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetLpuartFreq -* Description : Gets the clock frequency for LPUART module. -* This function gets the clock frequency for LPUART moudle. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance) -{ - clock_lpuart_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetLpuartSrc(SIM, instance); - - switch (src) - { - case kClockLpuartSrcIrc48M: /* IRC48M */ - freq = kMcgliteConst48M; - break; - case kClockLpuartSrcOsc0erClk: /* OSCER clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpuartSrcMcgIrClk: /* MCGIR clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetTpmExternalFreq -* Description : Gets Tpm external clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance) -{ - sim_tpm_clk_sel_t sel = SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); - - if (kSimTpmClkSel0 == sel) - { - return g_tpmClkFreq[0]; - } - else - { - return g_tpmClkFreq[1]; - } -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - clock_usbfs_src_t src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; - } - else - { - return kMcgliteConst48M; - } -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexioFreq - * Description : Gets the clock frequency for FLEXIO. - * This function gets the clock frequency for FLEXIO. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexioFreq(uint32_t instance) -{ - uint32_t freq; - clock_flexio_src_t src = CLOCK_HAL_GetFlexioSrc(SIM, instance); - - switch (src) - { - case kClockFlexioSrcIrc48M: - freq = kMcgliteConst48M; - break; - case kClockFlexioSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockFlexioSrcMcgIrClk: - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcSysClk: /*!< SYSCLK */ - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case kClockSaiSrcOsc0erClk: /*!< OSC0ERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcMcgIrClk: /*!< MCGIRCLK */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockSaiSrcIrc48M: /*!< MCGPCLK/IRC48M. */ - freq = kMcgliteConst48M; - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiFreq - * Description : Gets the clock frequency for SPI. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - assert(instance < SPI_INSTANCE_COUNT); - - if (0U == instance) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetSystemClockFreq(); - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnablePortClock -* Description : Enable the clock for PORT module -* This function enables the clock for PORT moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisablePortClock -* Description : Disable the clock for PORT module -* This function disables the clock for PORT moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetPortGateCmd -* Description : Get the the clock gate state for PORT module -* This function will get the clock gate state for PORT moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableAdcClock -* Description : Enable the clock for ADC module -* This function enables the clock for ADC moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableAdcClock -* Description : Disable the clock for ADC module -* This function disables the clock for ADC moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetAdcGateCmd -* Description : Get the the clock gate state for ADC module -* This function will get the clock gate state for ADC moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableSpiClock -* Description : Enable the clock for SPI module -* This function enables the clock for SPI moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableSpiClock -* Description : Disable the clock for SPI module -* This function disables the clock for SPI moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetSpiGateCmd -* Description : Get the the clock gate state for SPI module -* This function will get the clock gate state for SPI moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableI2cClock -* Description : Enable the clock for I2C module -* This function enables the clock for I2C moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableI2cClock -* Description : Disable the clock for I2C module -* This function disables the clock for I2C moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetI2cGateCmd -* Description : Get the the clock gate state for I2C module -* This function will get the clock gate state for I2C moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Lpuart instance table. */ -static const sim_clock_gate_name_t lpuartGateTable[] = -{ - kSimClockGateLpuart0, - kSimClockGateLpuart1 -}; - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_EnableLpuartClock -* Description : Enable the clock for UART module -* This function enables the clock for UART moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableLpuartClock(uint32_t instance) -{ - assert(instance < sizeof(lpuartGateTable)/sizeof(lpuartGateTable[0])); - - SIM_HAL_EnableClock(SIM, lpuartGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_DisableLpuartClock -* Description : Disable the clock for UART module -* This function enables the clock for UART moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableLpuartClock(uint32_t instance) -{ - assert(instance < sizeof(lpuartGateTable)/sizeof(lpuartGateTable[0])); - - SIM_HAL_DisableClock(SIM, lpuartGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_GetLpuartGateCmd -* Description : Get the the clock gate state for UART module -* This function will get the clock gate state for UART moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetLpuartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(lpuartGateTable)/sizeof(lpuartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, lpuartGateTable[instance]); -} - -/* TPM instance table. */ -static const sim_clock_gate_name_t tpmGateTable[] = -{ - kSimClockGateTpm0, - kSimClockGateTpm1, - kSimClockGateTpm2, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableTpmClock -* Description : Enable the clock for TPM module -* This function enables the clock for TPM moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_EnableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableTpmClock -* Description : Disable the clock for TPM module -* This function disables the clock for TPM moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_DisableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetTpmGateCmd -* Description : Get the the clock gate state for TPM module -* This function will get the clock gate state for TPM moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, tpmGateTable[instance]); -} - -/******************************************************************************* -* EOF -******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL33Z4/fsl_clock_MKL33Z4.h b/KSDK_1.2.0/platform/system/src/clock/MKL33Z4/fsl_clock_MKL33Z4.h deleted file mode 100644 index 488f9ba..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL33Z4/fsl_clock_MKL33Z4.h +++ /dev/null @@ -1,1323 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#if !defined(__FSL_CLOCK_MKL33Z4_H__) -#define __FSL_CLOCK_MKL33Z4_H__ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcglite_hal.h" -#include "fsl_mcglite_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kl33z4 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* -* Definitions -******************************************************************************/ -/*! @brief TPM external clock source count. */ -#define TPM_EXT_CLK_COUNT 2 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 - -/*! @brief TPM external clock frequency(TPM_CLK). */ -extern uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -#endif - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kl33z4_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* -* API -******************************************************************************/ -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! -* @brief Get internal reference clock frequency. -* -* This function gets the internal reference clock frequency. -* -* @return Current clock frequency. -*/ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! -* @brief Gets the OSC0ERCLK frequency. -* -* This function gets the OSC0 external reference frequency. -* -* @return Current frequency. -*/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! -* @brief Gets RTC_CLKOUT frequency. -* -* This function gets the frequency of RTC_CLKOUT. -* -* @return Current frequency. -*/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! -* @brief Gets RTC_CLKOUT source. -* -* This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. -* -* @return Current source. -*/ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! -* @brief Gets RTC_CLKOUT source. -* -* This function sets the source of RTC_CLKOUT. -* -* @param src RTC_CLKOUT source to set. -*/ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - - /*! - * @brief Gets rtc clock frequency. - * - * This function gets the rtc clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets COP clock frequency. - * - * This function gets the COP clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetCopFreq(void); - -/*! - * @brief Set the COP clock source selection. - * - * This function sets the COP clock source selection. - * - * @param copSrc The value to set. - */ -static inline void CLOCK_SYS_SetCopSrc(clock_cop_src_t copSrc) -{ - CLOCK_HAL_SetCopSrc(SIM, copSrc); -} - -/*! - * @brief Get the COP clock source selection. - * - * This function gets the COP clock source selection. - * - * @return Current selection. - */ -static inline clock_cop_src_t CLOCK_SYS_GetCopSrc(void) -{ - return CLOCK_HAL_GetCopSrc(SIM); -} - -/*! - * @brief Gets TPM clock frequency. - * - * This function gets the TPM clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance); - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param instance IP instance. - * @param tpmSrc The value to set. - */ -static inline void CLOCK_SYS_SetTpmSrc(uint32_t instance, clock_tpm_src_t tpmSrc) -{ - CLOCK_HAL_SetTpmSrc(SIM, instance, tpmSrc); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_SYS_GetTpmSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTpmSrc(SIM, instance); -} - -/*! - * @brief Get the TPM external clock source frequency. - * - * This function gets the TPM external clock source frequency. - * - * @param instance IP instance. - * @return TPM external clock frequency. - */ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance); - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @param src TPM external clock source. - */ -static inline void CLOCK_SYS_SetTpmExternalSrc(uint32_t instance, sim_tpm_clk_sel_t src) -{ - SIM_HAL_SetTpmExternalClkPinSelMode(SIM, instance, src); -} - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @return setting Current TPM external clock source. - */ -static inline sim_tpm_clk_sel_t CLOCK_SYS_GetTpmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @param usbfsSrc The value to set. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Gets the clock source for LPUART module - * - * This function gets the clock source for LPUART module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_lpuart_src_t CLOCK_SYS_GetLpuartSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpuartSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for LPUART module - * - * This function sets the clock source for LPUART module. - * @param instance module device instance - * @param lpuartSrc Clock source. - */ -static inline void CLOCK_SYS_SetLpuartSrc(uint32_t instance, clock_lpuart_src_t lpuartSrc) -{ - CLOCK_HAL_SetLpuartSrc(SIM, instance, lpuartSrc); -} - -/*! - * @brief Gets the clock frequency for LPUART module - * - * This function gets the clock frequency for LPUART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance); - -/*! - * @brief Gets FLEXIO clock frequency. - * - * This function gets the FLEXIO clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexioFreq(uint32_t instance); - -/*! - * @brief Set the FLEXIO clock source selection. - * - * This function sets the FLEXIO clock source selection. - * - * @param instance IP instance. - * @param flexioSrc The value to set. - */ -static inline void CLOCK_SYS_SetFlexioSrc(uint32_t instance, clock_flexio_src_t flexioSrc) -{ - CLOCK_HAL_SetFlexioSrc(SIM, instance, flexioSrc); -} - -/*! - * @brief Get the FLEXIO clock source selection. - * - * This function gets the FLEXIO clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_flexio_src_t CLOCK_SYS_GetFlexioSrc(uint32_t instance) -{ - return CLOCK_HAL_GetFlexioSrc(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -#if FSL_FEATURE_SOC_LCD_COUNT -/*! - * @brief Gets the frequency for SLCD default clock. - * - * This function gets the frequency for SLCD default clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdDefaultFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets the frequency for SLCD alternate clock. - * - * This function gets the frequency for SLCD alternate clock (ALTSOURCE = 0). - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAltFreq(uint32_t instance) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the frequency for SLCD alternate 2 clock. - * - * This function gets the frequency for SLCD alternate 2 clock (ALTSOURCE = 1). - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAlt2Freq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} -#endif// FSL_FEATURE_SOC_LCD_COUNT - -/*! -* @brief Gets the clock frequency for FTF module. (Flash Memory) -* -* This function gets the clock frequency for FTF module. (Flash Memory) -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets the clock frequency for CMP module. -* -* This function gets the clock frequency for CMP module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets the clock frequency for VREF module. -* -* This function gets the clock frequency for VREF module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets the clock frequency for SPI module -* -* This function gets the clock frequency for SPI module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance); - -/*! -* @brief Gets the clock frequency for I2C module -* -* This function gets the clock frequency for I2C module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets ADC alternate clock frequency. -* -* This function gets the ADC alternate clock frequency. -* -* @param instance module device instance -* @return freq Current frequency. -*/ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! -* @brief Gets the clock frequency for UART module -* -* This function gets the clock frequency for UART module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Enable the clock for PORT module. -* -* This function enables the clock for PORT module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! -* @brief Disable the clock for PORT module. -* -* This function disables the clock for PORT module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for PORT module. -* -* This function will get the clock gate state for PORT module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_LCD_COUNT -/*! -* @brief Enable the clock for SLCD module. -* -* This function enables the clock for SLCD module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableSlcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSlcd0); -} - -/*! -* @brief Disable the clock for SLCD module. -* -* This function disables the clock for SLCD module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableSlcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSlcd0); -} - -/*! -* @brief Get the the clock gate state for SLCD module. -* -* This function will get the clock gate state for SLCD module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetSlcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSlcd0); -} -#endif// FSL_FEATURE_SOC_LCD_COUNT - -/*! -* @brief Enable the clock for FTF module. -* -* This function enables the clock for FTF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! -* @brief Disable the clock for FTF module. -* -* This function disables the clock for FTF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! -* @brief Get the the clock gate state for FTF module. -* -* This function will get the clock gate state for FTF module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! -* @brief Enable the clock for ADC module. -* -* This function enables the clock for ADC module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! -* @brief Disable the clock for ADC module. -* -* This function disables the clock for ADC module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for ADC module. -* -* This function will get the clock gate state for ADC module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for CMP module. -* -* This function enables the clock for CMP module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp0); -} - -/*! -* @brief Disable the clock for CMP module. -* -* This function disables the clock for CMP module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp0); -} - -/*! -* @brief Get the the clock gate state for CMP module. -* -* This function will get the clock gate state for CMP module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp0); -} - -/*! -* @brief Enable the clock for VREF module. -* -* This function enables the clock for VREF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! -* @brief Disable the clock for VREF module. -* -* This function disables the clock for VREF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! -* @brief Get the the clock gate state for VREF module. -* -* This function will get the clock gate state for VREF module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! -* @brief Enable the clock for LPTIMER module. -* -* This function enables the clock for LPTIMER module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! -* @brief Disable the clock for LPTIMER module. -* -* This function disables the clock for LPTIMER module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! -* @brief Get the the clock gate state for LPTIMER module. -* -* This function will get the clock gate state for LPTIMER module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! -* @brief Enable the clock for RTC module. -* -* This function enables the clock for RTC module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! -* @brief Disable the clock for RTC module. -* -* This function disables the clock for RTC module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! -* @brief Get the the clock gate state for RTC module. -* -* This function will get the clock gate state for RTC module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! -* @brief Enable the clock for DAC module. -* -* This function enables the clock for DAC module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDac0); -} - -/*! -* @brief Disable the clock for DAC module. -* -* This function disables the clock for DAC module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDac0); -} - -/*! -* @brief Get the the clock gate state for DAC module. -* -* This function will get the clock gate state for DAC module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDac0); -} - -/*! -* @brief Enable the clock for SPI module. -* -* This function enables the clock for SPI module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! -* @brief Disable the clock for SPI module. -* -* This function disables the clock for SPI module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for SPI module. -* -* This function will get the clock gate state for SPI module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for I2C module. -* -* This function enables the clock for I2C module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! -* @brief Disable the clock for I2C module. -* -* This function disables the clock for I2C module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for I2C module. -* -* This function will get the clock gate state for I2C module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for LPUART module. -* -* This function enables the clock for LPUART module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableLpuartClock(uint32_t instance); - -/*! -* @brief Disable the clock for LPUART module. -* -* This function disables the clock for LPUART module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableLpuartClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for LPUART module. -* -* This function will get the clock gate state for LPUART module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetLpuartGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for UART module. -* -* This function enables the clock for UART module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUart2); -} - -/*! -* @brief Disable the clock for UART module. -* -* This function disables the clock for UART module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUart2); -} - -/*! -* @brief Get the the clock gate state for UART module. -* -* This function will get the clock gate state for UART module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM,kSimClockGateUart2); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! -* @brief Enable the clock for FLEXIO module. -* -* This function enables the clock for FLEXIO module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableFlexioClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexio0); -} - -/*! -* @brief Disable the clock for FLEXIO module. -* -* This function disables the clock for FLEXIO module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableFlexioClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexio0); -} - -/*! -* @brief Get the clock gate state for FLEXIO module. -* -* This function will get the clock gate state for FLEXIO module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetFlexioGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM,kSimClockGateFlexio0); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for TPM module. - * - * This function enables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableTpmClock(uint32_t instance); - -/*! - * @brief Disable the clock for TPM module. - * - * This function disables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableTpmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for TPM module. - * - * This function will get the clock gate state for TPM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Set the TPM external clock frequency(TPM_CLKx). - * - * This function sets the TPM external clock frequency (TPM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetTpmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < TPM_EXT_CLK_COUNT); - - g_tpmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - - -#endif /* __FSL_CLOCK_MKL33Z4__H__ */ -/******************************************************************************* -* EOF -******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL34Z4/fsl_clock_MKL34Z4.c b/KSDK_1.2.0/platform/system/src/clock/MKL34Z4/fsl_clock_MKL34Z4.c deleted file mode 100755 index 71d7a5b..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL34Z4/fsl_clock_MKL34Z4.c +++ /dev/null @@ -1,1012 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" -#include "fsl_mcg_hal.h" -#include "fsl_clock_manager.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; /* TPM_CLK */ -#if FSL_FEATURE_SOC_USB_COUNT -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -#endif - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - 0U, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - - CLOCK_HAL_SetOutDiv(SIM, 2U, 0U, 0U, 5U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - - /*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the systen clock frequency. - * This function gets the systen clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - freq >>= 1U; /* divided by 2 for special divider */ - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return CLOCK_SYS_GetExternalRefClock32kFreq() >> 15U; - } - else - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCopFreq - * Description : Gets COP clock frequency. - * This function gets the COP clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCopFreq(uint32_t instance, clock_cop_src_t copSrc) -{ - if (kClockCopSrcLpoClk == copSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcFreq - * Description : Gets rtc clock frequency. - * This function gets rtc clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmfFreq - * Description : Gets the clock frequency for TPM module. - * This function gets the clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance) -{ - uint32_t freq; - clock_tpm_src_t src; - - src = CLOCK_HAL_GetTpmSrc(SIM, instance); - - switch(src) - { - case kClockTpmSrcPllFllSel: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTpmSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTpmSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmExternalFreq - * Description : Gets the external clock frequency for TPM module. - * This function gets the external clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance) -{ - sim_tpm_clk_sel_t src = CLOCK_SYS_GetTpmExternalSrc(instance); - - if (kSimTpmClkSel0 == src) - { - return g_tpmClkFreq[0]; - } - else - { - return g_tpmClkFreq[1]; - } -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - return freq; - } -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpifFreq - * Description : Gets the clock frequency for SPI module. - * This function gets the clock frequency for SPI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetBusClockFreq(); /* BUS CLOCK */ - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); /* SYSTEM CLOCK*/ - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cfFreq - * Description : Gets the clock frequency for I2C module. - * This function gets the clock frequency for I2C moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetBusClockFreq(); /* BUS CLOCK */ - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); /* SYSTEM CLOCK*/ - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLpsciFreq - * Description : Gets the clock frequency for LPSCI module. - * This function gets the clock frequency for LPSCI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpsciFreq(uint32_t instance) -{ - uint32_t freq; - clock_lpsci_src_t src; - - src = CLOCK_HAL_GetLpsciSrc(SIM, instance); - - switch(src) - { - case kClockLpsciSrcPllFllSel: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockLpsciSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpsciSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq = 0; - - switch (instance) - { - case 0: - case 1: - case 2: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Lpsci instance table. */ -static const sim_clock_gate_name_t lpsciGateTable[] = -{ - kSimClockGateLpsci0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableLpsciClock - * Description : Enable the clock for LPSCI module - * This function disable the clock for LPSCI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableLpsciClock(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - SIM_HAL_DisableClock(SIM, lpsciGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetLpsciGateCmd - * Description : Get the the clock gate state for LPSCI module - * This function will get the clock gate state for LPSCI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetLpsciGateCmd(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, lpsciGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableLpsciClock - * Description : Enable the clock for LPSCI module - * This function enables the clock for LPSCI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableLpsciClock(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - SIM_HAL_EnableClock(SIM, lpsciGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - (sim_clock_gate_name_t)(-1), - kSimClockGateUart1, - kSimClockGateUart2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t tpmGateTable[] = -{ - kSimClockGateTpm0, - kSimClockGateTpm1, - kSimClockGateTpm2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableTpmClock - * Description : Enable the clock for TPM module - * This function enables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_EnableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableTpmClock - * Description : Disable the clock for TPM module - * This function disables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_DisableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmGateCmd - * Description : Get the the clock gate state for TPM module - * This function will get the clock gate state for TPM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, tpmGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL34Z4/fsl_clock_MKL34Z4.h b/KSDK_1.2.0/platform/system/src/clock/MKL34Z4/fsl_clock_MKL34Z4.h deleted file mode 100644 index 4efb54c..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL34Z4/fsl_clock_MKL34Z4.h +++ /dev/null @@ -1,1237 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KL34Z4_H__) -#define __FSL_CLOCK_KL34Z4_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kl34z4 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief TPM external clock source count. */ -#define TPM_EXT_CLK_COUNT 2 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 - -/*! @brief TPM external clock frequency(TPM_CLK). */ -extern uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -#endif - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kl34z4_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the COP clock frequency. - * - * This function gets the COP clock frequency. - * - * @param instance module device instance - * @param copSrc COP clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetCopFreq(uint32_t instance, clock_cop_src_t copSrc); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets TPM clock frequency. - * - * This function gets the TPM clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance); - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param instance IP instance. - * @param tpmSrc The value to set. - */ -static inline void CLOCK_SYS_SetTpmSrc(uint32_t instance, clock_tpm_src_t tpmSrc) -{ - CLOCK_HAL_SetTpmSrc(SIM, instance, tpmSrc); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_SYS_GetTpmSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTpmSrc(SIM, instance); -} - -/*! - * @brief Get the TPM external clock source frequency. - * - * This function gets the TPM external clock source frequency. - * - * @param instance IP instance. - * @return TPM external clock frequency. - */ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance); - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @param src TPM external clock source. - */ -static inline void CLOCK_SYS_SetTpmExternalSrc(uint32_t instance, sim_tpm_clk_sel_t src) -{ - SIM_HAL_SetTpmExternalClkPinSelMode(SIM, instance, src); -} - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @return setting Current TPM external clock source. - */ -static inline sim_tpm_clk_sel_t CLOCK_SYS_GetTpmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @param usbfsSrc The value to set. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance); - - /*! - * @brief Gets the clock frequency for LPSCI module. - * - * This function gets the clock frequency for LPSCI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpsciFreq(uint32_t instance); - -/*! - * @brief Set the LPSCI clock source selection. - * - * This function sets the LPSCI clock source selection. - * - * @param instance IP instance. - * @param lpsciSrc The value to set. - */ -static inline void CLOCK_SYS_SetLpsciSrc(uint32_t instance, clock_lpsci_src_t lpsciSrc) -{ - CLOCK_HAL_SetLpsciSrc(SIM, instance, lpsciSrc); -} - -/*! - * @brief Get the LPSCI clock source selection. - * - * This function gets the LPSCI clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_lpsci_src_t CLOCK_SYS_GetLpsciSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpsciSrc(SIM, instance); -} - -/*! - * @brief Get the UART clock frequency. - * - * This function gets the UART clock frequency. - * - * @param instance IP instance. - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_LCD_COUNT -/*! - * @brief Enable the clock for SLCD module. - * - * This function enables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSlcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Disable the clock for SLCD module. - * - * This function disables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSlcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Get the the clock gate state for SLCD module. - * - * This function will get the clock gate state for SLCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSlcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Gets the frequency for SLCD default clock. - * - * This function gets the frequency for SLCD default clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdDefaultFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets the frequency for SLCD alternate clock. - * - * This function gets the frequency for SLCD alternate clock (ALTSOURCE = 0). - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAltFreq(uint32_t instance) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the frequency for SLCD alternate 2 clock. - * - * This function gets the frequency for SLCD alternate 2 clock (ALTSOURCE = 1). - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAlt2Freq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} -#endif// FSL_FEATURE_SOC_LCD_COUNT - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for TPM module. - * - * This function enables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableTpmClock(uint32_t instance); - -/*! - * @brief Disable the clock for TPM module. - * - * This function disables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableTpmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for TPM module. - * - * This function will get the clock gate state for TPM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for TSI module. - * - * This function enables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTsiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Disable the clock for TSI module. - * - * This function disables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTsiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Get the the clock gate state for TSI module. - * - * This function will get the clock gate state for TSI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTsiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTsi0); -} - - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for LPSCI module. - * - * This function enables the clock for LPSCI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableLpsciClock(uint32_t instance); - -/*! - * @brief Disable the clock for LPSCI module. - * - * This function disables the clock for LPSCI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableLpsciClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for LPSCI module. - * - * This function will get the clock gate state for LPSCI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetLpsciGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Set the TPM external clock frequency(TPM_CLKx). - * - * This function sets the TPM external clock frequency (TPM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetTpmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < TPM_EXT_CLK_COUNT); - - g_tpmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KL34Z4_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL36Z4/fsl_clock_MKL36Z4.c b/KSDK_1.2.0/platform/system/src/clock/MKL36Z4/fsl_clock_MKL36Z4.c deleted file mode 100755 index 71d7a5b..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL36Z4/fsl_clock_MKL36Z4.c +++ /dev/null @@ -1,1012 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" -#include "fsl_mcg_hal.h" -#include "fsl_clock_manager.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; /* TPM_CLK */ -#if FSL_FEATURE_SOC_USB_COUNT -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -#endif - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - 0U, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - - CLOCK_HAL_SetOutDiv(SIM, 2U, 0U, 0U, 5U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - - /*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the systen clock frequency. - * This function gets the systen clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - freq >>= 1U; /* divided by 2 for special divider */ - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return CLOCK_SYS_GetExternalRefClock32kFreq() >> 15U; - } - else - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCopFreq - * Description : Gets COP clock frequency. - * This function gets the COP clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCopFreq(uint32_t instance, clock_cop_src_t copSrc) -{ - if (kClockCopSrcLpoClk == copSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcFreq - * Description : Gets rtc clock frequency. - * This function gets rtc clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmfFreq - * Description : Gets the clock frequency for TPM module. - * This function gets the clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance) -{ - uint32_t freq; - clock_tpm_src_t src; - - src = CLOCK_HAL_GetTpmSrc(SIM, instance); - - switch(src) - { - case kClockTpmSrcPllFllSel: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTpmSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTpmSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmExternalFreq - * Description : Gets the external clock frequency for TPM module. - * This function gets the external clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance) -{ - sim_tpm_clk_sel_t src = CLOCK_SYS_GetTpmExternalSrc(instance); - - if (kSimTpmClkSel0 == src) - { - return g_tpmClkFreq[0]; - } - else - { - return g_tpmClkFreq[1]; - } -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - return freq; - } -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpifFreq - * Description : Gets the clock frequency for SPI module. - * This function gets the clock frequency for SPI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetBusClockFreq(); /* BUS CLOCK */ - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); /* SYSTEM CLOCK*/ - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cfFreq - * Description : Gets the clock frequency for I2C module. - * This function gets the clock frequency for I2C moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetBusClockFreq(); /* BUS CLOCK */ - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); /* SYSTEM CLOCK*/ - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLpsciFreq - * Description : Gets the clock frequency for LPSCI module. - * This function gets the clock frequency for LPSCI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpsciFreq(uint32_t instance) -{ - uint32_t freq; - clock_lpsci_src_t src; - - src = CLOCK_HAL_GetLpsciSrc(SIM, instance); - - switch(src) - { - case kClockLpsciSrcPllFllSel: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockLpsciSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpsciSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq = 0; - - switch (instance) - { - case 0: - case 1: - case 2: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Lpsci instance table. */ -static const sim_clock_gate_name_t lpsciGateTable[] = -{ - kSimClockGateLpsci0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableLpsciClock - * Description : Enable the clock for LPSCI module - * This function disable the clock for LPSCI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableLpsciClock(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - SIM_HAL_DisableClock(SIM, lpsciGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetLpsciGateCmd - * Description : Get the the clock gate state for LPSCI module - * This function will get the clock gate state for LPSCI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetLpsciGateCmd(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, lpsciGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableLpsciClock - * Description : Enable the clock for LPSCI module - * This function enables the clock for LPSCI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableLpsciClock(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - SIM_HAL_EnableClock(SIM, lpsciGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - (sim_clock_gate_name_t)(-1), - kSimClockGateUart1, - kSimClockGateUart2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t tpmGateTable[] = -{ - kSimClockGateTpm0, - kSimClockGateTpm1, - kSimClockGateTpm2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableTpmClock - * Description : Enable the clock for TPM module - * This function enables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_EnableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableTpmClock - * Description : Disable the clock for TPM module - * This function disables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_DisableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmGateCmd - * Description : Get the the clock gate state for TPM module - * This function will get the clock gate state for TPM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, tpmGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL36Z4/fsl_clock_MKL36Z4.h b/KSDK_1.2.0/platform/system/src/clock/MKL36Z4/fsl_clock_MKL36Z4.h deleted file mode 100644 index 5824784..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL36Z4/fsl_clock_MKL36Z4.h +++ /dev/null @@ -1,1237 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KL36Z4_H__) -#define __FSL_CLOCK_KL36Z4_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kl36z4 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief TPM external clock source count. */ -#define TPM_EXT_CLK_COUNT 2 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 - -/*! @brief TPM external clock frequency(TPM_CLK). */ -extern uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -#endif - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kl36z4_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the COP clock frequency. - * - * This function gets the COP clock frequency. - * - * @param instance module device instance - * @param copSrc COP clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetCopFreq(uint32_t instance, clock_cop_src_t copSrc); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets TPM clock frequency. - * - * This function gets the TPM clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance); - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param instance IP instance. - * @param tpmSrc The value to set. - */ -static inline void CLOCK_SYS_SetTpmSrc(uint32_t instance, clock_tpm_src_t tpmSrc) -{ - CLOCK_HAL_SetTpmSrc(SIM, instance, tpmSrc); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_SYS_GetTpmSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTpmSrc(SIM, instance); -} - -/*! - * @brief Get the TPM external clock source frequency. - * - * This function gets the TPM external clock source frequency. - * - * @param instance IP instance. - * @return TPM external clock frequency. - */ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance); - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @param src TPM external clock source. - */ -static inline void CLOCK_SYS_SetTpmExternalSrc(uint32_t instance, sim_tpm_clk_sel_t src) -{ - SIM_HAL_SetTpmExternalClkPinSelMode(SIM, instance, src); -} - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @return setting Current TPM external clock source. - */ -static inline sim_tpm_clk_sel_t CLOCK_SYS_GetTpmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @param usbfsSrc The value to set. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance); - - /*! - * @brief Gets the clock frequency for LPSCI module. - * - * This function gets the clock frequency for LPSCI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpsciFreq(uint32_t instance); - -/*! - * @brief Set the LPSCI clock source selection. - * - * This function sets the LPSCI clock source selection. - * - * @param instance IP instance. - * @param lpsciSrc The value to set. - */ -static inline void CLOCK_SYS_SetLpsciSrc(uint32_t instance, clock_lpsci_src_t lpsciSrc) -{ - CLOCK_HAL_SetLpsciSrc(SIM, instance, lpsciSrc); -} - -/*! - * @brief Get the LPSCI clock source selection. - * - * This function gets the LPSCI clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_lpsci_src_t CLOCK_SYS_GetLpsciSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpsciSrc(SIM, instance); -} - -/*! - * @brief Get the UART clock frequency. - * - * This function gets the UART clock frequency. - * - * @param instance IP instance. - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_LCD_COUNT -/*! - * @brief Enable the clock for SLCD module. - * - * This function enables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSlcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Disable the clock for SLCD module. - * - * This function disables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSlcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Get the the clock gate state for SLCD module. - * - * This function will get the clock gate state for SLCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSlcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Gets the frequency for SLCD default clock. - * - * This function gets the frequency for SLCD default clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdDefaultFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets the frequency for SLCD alternate clock. - * - * This function gets the frequency for SLCD alternate clock (ALTSOURCE = 0). - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAltFreq(uint32_t instance) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the frequency for SLCD alternate 2 clock. - * - * This function gets the frequency for SLCD alternate 2 clock (ALTSOURCE = 1). - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAlt2Freq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} -#endif// FSL_FEATURE_SOC_LCD_COUNT - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for TPM module. - * - * This function enables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableTpmClock(uint32_t instance); - -/*! - * @brief Disable the clock for TPM module. - * - * This function disables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableTpmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for TPM module. - * - * This function will get the clock gate state for TPM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for TSI module. - * - * This function enables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTsiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Disable the clock for TSI module. - * - * This function disables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTsiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Get the the clock gate state for TSI module. - * - * This function will get the clock gate state for TSI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTsiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTsi0); -} - - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for LPSCI module. - * - * This function enables the clock for LPSCI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableLpsciClock(uint32_t instance); - -/*! - * @brief Disable the clock for LPSCI module. - * - * This function disables the clock for LPSCI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableLpsciClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for LPSCI module. - * - * This function will get the clock gate state for LPSCI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetLpsciGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Set the TPM external clock frequency(TPM_CLKx). - * - * This function sets the TPM external clock frequency (TPM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetTpmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < TPM_EXT_CLK_COUNT); - - g_tpmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KL36Z4_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL43Z4/fsl_clock_MKL43Z4.c b/KSDK_1.2.0/platform/system/src/clock/MKL43Z4/fsl_clock_MKL43Z4.c deleted file mode 100755 index d74eea3..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL43Z4/fsl_clock_MKL43Z4.c +++ /dev/null @@ -1,840 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcglite_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* -* README: -* This file should provide these APIs: -* 1. APIs to get the frequency of output clocks in Reference Manual -> -* Chapter Clock Distribution -> Figure Clocking diagram. -* 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution -* -> Module clocks. -*/ - -/******************************************************************************* -* Definitions -******************************************************************************/ -uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; /* TPM_CLK */ -#if FSL_FEATURE_SOC_USB_COUNT -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -#endif - -/******************************************************************************* -* Code -******************************************************************************/ - - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - 0U, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 1U, 0U, 0U, 7U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgliteMode(&config->mcgliteConfig); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kIrc48mClock: - *frequency = kMcgliteConst48M; - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetCoreClockFreq -* Description : Gets the core clock frequency. -* This function gets the core clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetSystemClockFreq -* Description : Gets the systen clock frequency. -* This function gets the systen clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetBusClockFreq -* Description : Gets the bus clock frequency. -* This function gets the bus clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetFlashClockFreq -* Description : Gets the flash clock frequency. -* This function gets the flash clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetRtcOutFreq -* Description : Gets the RTC_CLKOUT frequency. -* This function gets RTC_CLKOUT clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return 1U; - } - else - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetExternalRefClockFreq -* Description : Gets the ERCLK32K clock frequency. -* This function gets the external reference (ERCLK32K) clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq -* Description : Gets OSC0ERCLK. -* This function gets the OSC0 external reference frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetCopFreq -* Description : Gets the clock frequency for COP module. -* This function gets the clock frequency for COP moudle. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetCopFreq(void) -{ - clock_cop_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetCopSrc(SIM); - - switch (src) - { - case kClockCopSrcLpoClk: - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockCopSrcMcgIrClk: - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockCopSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockCopSrcBusClk: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetTpmFreq -* Description : Gets the clock frequency for TPM module. -* This function gets the clock frequency for TPM moudle. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance) -{ - - clock_tpm_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetTpmSrc(SIM, instance); - - switch (src) - { - case kClockTpmSrcIrc48M: /* IRC48M */ - freq = kMcgliteConst48M; - break; - case kClockTpmSrcOsc0erClk: /* OSCER clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTpmSrcMcgIrClk: /* MCGIR clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetLpuartFreq -* Description : Gets the clock frequency for LPUART module. -* This function gets the clock frequency for LPUART moudle. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance) -{ - clock_lpuart_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetLpuartSrc(SIM, instance); - - switch (src) - { - case kClockLpuartSrcIrc48M: /* IRC48M */ - freq = kMcgliteConst48M; - break; - case kClockLpuartSrcOsc0erClk: /* OSCER clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpuartSrcMcgIrClk: /* MCGIR clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetTpmExternalFreq -* Description : Gets Tpm external clock frequency. -* -*END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance) -{ - sim_tpm_clk_sel_t sel = SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); - - if (kSimTpmClkSel0 == sel) - { - return g_tpmClkFreq[0]; - } - else - { - return g_tpmClkFreq[1]; - } -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - clock_usbfs_src_t src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; - } - else - { - return kMcgliteConst48M; - } -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexioFreq - * Description : Gets the clock frequency for FLEXIO. - * This function gets the clock frequency for FLEXIO. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexioFreq(uint32_t instance) -{ - uint32_t freq; - clock_flexio_src_t src = CLOCK_HAL_GetFlexioSrc(SIM, instance); - - switch (src) - { - case kClockFlexioSrcIrc48M: - freq = kMcgliteConst48M; - break; - case kClockFlexioSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockFlexioSrcMcgIrClk: - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcSysClk: /*!< SYSCLK */ - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case kClockSaiSrcOsc0erClk: /*!< OSC0ERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcMcgIrClk: /*!< MCGIRCLK */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockSaiSrcIrc48M: /*!< MCGPCLK/IRC48M. */ - freq = kMcgliteConst48M; - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiFreq - * Description : Gets the clock frequency for SPI. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - assert(instance < SPI_INSTANCE_COUNT); - - if (0U == instance) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetSystemClockFreq(); - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnablePortClock -* Description : Enable the clock for PORT module -* This function enables the clock for PORT moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisablePortClock -* Description : Disable the clock for PORT module -* This function disables the clock for PORT moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetPortGateCmd -* Description : Get the the clock gate state for PORT module -* This function will get the clock gate state for PORT moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableAdcClock -* Description : Enable the clock for ADC module -* This function enables the clock for ADC moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableAdcClock -* Description : Disable the clock for ADC module -* This function disables the clock for ADC moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetAdcGateCmd -* Description : Get the the clock gate state for ADC module -* This function will get the clock gate state for ADC moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableSpiClock -* Description : Enable the clock for SPI module -* This function enables the clock for SPI moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableSpiClock -* Description : Disable the clock for SPI module -* This function disables the clock for SPI moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetSpiGateCmd -* Description : Get the the clock gate state for SPI module -* This function will get the clock gate state for SPI moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableI2cClock -* Description : Enable the clock for I2C module -* This function enables the clock for I2C moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableI2cClock -* Description : Disable the clock for I2C module -* This function disables the clock for I2C moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetI2cGateCmd -* Description : Get the the clock gate state for I2C module -* This function will get the clock gate state for I2C moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Lpuart instance table. */ -static const sim_clock_gate_name_t lpuartGateTable[] = -{ - kSimClockGateLpuart0, - kSimClockGateLpuart1 -}; - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_EnableLpuartClock -* Description : Enable the clock for UART module -* This function enables the clock for UART moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableLpuartClock(uint32_t instance) -{ - assert(instance < sizeof(lpuartGateTable)/sizeof(lpuartGateTable[0])); - - SIM_HAL_EnableClock(SIM, lpuartGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_DisableLpuartClock -* Description : Disable the clock for UART module -* This function enables the clock for UART moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableLpuartClock(uint32_t instance) -{ - assert(instance < sizeof(lpuartGateTable)/sizeof(lpuartGateTable[0])); - - SIM_HAL_DisableClock(SIM, lpuartGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : SIM_HAL_GetLpuartGateCmd -* Description : Get the the clock gate state for UART module -* This function will get the clock gate state for UART moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetLpuartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(lpuartGateTable)/sizeof(lpuartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, lpuartGateTable[instance]); -} - -/* TPM instance table. */ -static const sim_clock_gate_name_t tpmGateTable[] = -{ - kSimClockGateTpm0, - kSimClockGateTpm1, - kSimClockGateTpm2, -}; - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_EnableTpmClock -* Description : Enable the clock for TPM module -* This function enables the clock for TPM moudle -* -*END**************************************************************************/ -void CLOCK_SYS_EnableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_EnableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_DisableTpmClock -* Description : Disable the clock for TPM module -* This function disables the clock for TPM moudle -* -*END**************************************************************************/ -void CLOCK_SYS_DisableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_DisableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** -* -* Function Name : CLOCK_SYS_GetTpmGateCmd -* Description : Get the the clock gate state for TPM module -* This function will get the clock gate state for TPM moudle. -* -*END**************************************************************************/ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, tpmGateTable[instance]); -} - -/******************************************************************************* -* EOF -******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL43Z4/fsl_clock_MKL43Z4.h b/KSDK_1.2.0/platform/system/src/clock/MKL43Z4/fsl_clock_MKL43Z4.h deleted file mode 100644 index 4786b28..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL43Z4/fsl_clock_MKL43Z4.h +++ /dev/null @@ -1,1323 +0,0 @@ -/* -* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* o Redistributions of source code must retain the above copyright notice, this list -* of conditions and the following disclaimer. -* -* o Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* o Neither the name of Freescale Semiconductor, Inc. nor the names of its -* contributors may be used to endorse or promote products derived from this -* software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#if !defined(__FSL_CLOCK_MKL43Z4_H__) -#define __FSL_CLOCK_MKL43Z4_H__ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcglite_hal.h" -#include "fsl_mcglite_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kl43z4 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* -* Definitions -******************************************************************************/ -/*! @brief TPM external clock source count. */ -#define TPM_EXT_CLK_COUNT 2 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 - -/*! @brief TPM external clock frequency(TPM_CLK). */ -extern uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -#endif - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kl43z4_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* -* API -******************************************************************************/ -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! -* @brief Get internal reference clock frequency. -* -* This function gets the internal reference clock frequency. -* -* @return Current clock frequency. -*/ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! -* @brief Gets the OSC0ERCLK frequency. -* -* This function gets the OSC0 external reference frequency. -* -* @return Current frequency. -*/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! -* @brief Gets RTC_CLKOUT frequency. -* -* This function gets the frequency of RTC_CLKOUT. -* -* @return Current frequency. -*/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! -* @brief Gets RTC_CLKOUT source. -* -* This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. -* -* @return Current source. -*/ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! -* @brief Gets RTC_CLKOUT source. -* -* This function sets the source of RTC_CLKOUT. -* -* @param src RTC_CLKOUT source to set. -*/ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - - /*! - * @brief Gets rtc clock frequency. - * - * This function gets the rtc clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets COP clock frequency. - * - * This function gets the COP clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetCopFreq(void); - -/*! - * @brief Set the COP clock source selection. - * - * This function sets the COP clock source selection. - * - * @param copSrc The value to set. - */ -static inline void CLOCK_SYS_SetCopSrc(clock_cop_src_t copSrc) -{ - CLOCK_HAL_SetCopSrc(SIM, copSrc); -} - -/*! - * @brief Get the COP clock source selection. - * - * This function gets the COP clock source selection. - * - * @return Current selection. - */ -static inline clock_cop_src_t CLOCK_SYS_GetCopSrc(void) -{ - return CLOCK_HAL_GetCopSrc(SIM); -} - -/*! - * @brief Gets TPM clock frequency. - * - * This function gets the TPM clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance); - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param instance IP instance. - * @param tpmSrc The value to set. - */ -static inline void CLOCK_SYS_SetTpmSrc(uint32_t instance, clock_tpm_src_t tpmSrc) -{ - CLOCK_HAL_SetTpmSrc(SIM, instance, tpmSrc); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_SYS_GetTpmSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTpmSrc(SIM, instance); -} - -/*! - * @brief Get the TPM external clock source frequency. - * - * This function gets the TPM external clock source frequency. - * - * @param instance IP instance. - * @return TPM external clock frequency. - */ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance); - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @param src TPM external clock source. - */ -static inline void CLOCK_SYS_SetTpmExternalSrc(uint32_t instance, sim_tpm_clk_sel_t src) -{ - SIM_HAL_SetTpmExternalClkPinSelMode(SIM, instance, src); -} - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @return setting Current TPM external clock source. - */ -static inline sim_tpm_clk_sel_t CLOCK_SYS_GetTpmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @param usbfsSrc The value to set. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Gets the clock source for LPUART module - * - * This function gets the clock source for LPUART module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_lpuart_src_t CLOCK_SYS_GetLpuartSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpuartSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for LPUART module - * - * This function sets the clock source for LPUART module. - * @param instance module device instance - * @param lpuartSrc Clock source. - */ -static inline void CLOCK_SYS_SetLpuartSrc(uint32_t instance, clock_lpuart_src_t lpuartSrc) -{ - CLOCK_HAL_SetLpuartSrc(SIM, instance, lpuartSrc); -} - -/*! - * @brief Gets the clock frequency for LPUART module - * - * This function gets the clock frequency for LPUART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance); - -/*! - * @brief Gets FLEXIO clock frequency. - * - * This function gets the FLEXIO clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexioFreq(uint32_t instance); - -/*! - * @brief Set the FLEXIO clock source selection. - * - * This function sets the FLEXIO clock source selection. - * - * @param instance IP instance. - * @param flexioSrc The value to set. - */ -static inline void CLOCK_SYS_SetFlexioSrc(uint32_t instance, clock_flexio_src_t flexioSrc) -{ - CLOCK_HAL_SetFlexioSrc(SIM, instance, flexioSrc); -} - -/*! - * @brief Get the FLEXIO clock source selection. - * - * This function gets the FLEXIO clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_flexio_src_t CLOCK_SYS_GetFlexioSrc(uint32_t instance) -{ - return CLOCK_HAL_GetFlexioSrc(SIM, instance); -} - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -#if FSL_FEATURE_SOC_LCD_COUNT -/*! - * @brief Gets the frequency for SLCD default clock. - * - * This function gets the frequency for SLCD default clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdDefaultFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets the frequency for SLCD alternate clock. - * - * This function gets the frequency for SLCD alternate clock (ALTSOURCE = 0). - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAltFreq(uint32_t instance) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the frequency for SLCD alternate 2 clock. - * - * This function gets the frequency for SLCD alternate 2 clock (ALTSOURCE = 1). - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAlt2Freq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} -#endif// FSL_FEATURE_SOC_LCD_COUNT - -/*! -* @brief Gets the clock frequency for FTF module. (Flash Memory) -* -* This function gets the clock frequency for FTF module. (Flash Memory) -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets the clock frequency for CMP module. -* -* This function gets the clock frequency for CMP module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets the clock frequency for VREF module. -* -* This function gets the clock frequency for VREF module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets the clock frequency for SPI module -* -* This function gets the clock frequency for SPI module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance); - -/*! -* @brief Gets the clock frequency for I2C module -* -* This function gets the clock frequency for I2C module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Gets ADC alternate clock frequency. -* -* This function gets the ADC alternate clock frequency. -* -* @param instance module device instance -* @return freq Current frequency. -*/ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! -* @brief Gets the clock frequency for UART module -* -* This function gets the clock frequency for UART module. -* @param instance module device instance -* @return freq clock frequency for this module -*/ -static inline uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! -* @brief Enable the clock for PORT module. -* -* This function enables the clock for PORT module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! -* @brief Disable the clock for PORT module. -* -* This function disables the clock for PORT module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for PORT module. -* -* This function will get the clock gate state for PORT module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_LCD_COUNT -/*! -* @brief Enable the clock for SLCD module. -* -* This function enables the clock for SLCD module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableSlcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSlcd0); -} - -/*! -* @brief Disable the clock for SLCD module. -* -* This function disables the clock for SLCD module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableSlcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSlcd0); -} - -/*! -* @brief Get the the clock gate state for SLCD module. -* -* This function will get the clock gate state for SLCD module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetSlcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSlcd0); -} -#endif// FSL_FEATURE_SOC_LCD_COUNT - -/*! -* @brief Enable the clock for FTF module. -* -* This function enables the clock for FTF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! -* @brief Disable the clock for FTF module. -* -* This function disables the clock for FTF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! -* @brief Get the the clock gate state for FTF module. -* -* This function will get the clock gate state for FTF module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! -* @brief Enable the clock for ADC module. -* -* This function enables the clock for ADC module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! -* @brief Disable the clock for ADC module. -* -* This function disables the clock for ADC module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for ADC module. -* -* This function will get the clock gate state for ADC module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for CMP module. -* -* This function enables the clock for CMP module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp0); -} - -/*! -* @brief Disable the clock for CMP module. -* -* This function disables the clock for CMP module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp0); -} - -/*! -* @brief Get the the clock gate state for CMP module. -* -* This function will get the clock gate state for CMP module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp0); -} - -/*! -* @brief Enable the clock for VREF module. -* -* This function enables the clock for VREF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! -* @brief Disable the clock for VREF module. -* -* This function disables the clock for VREF module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! -* @brief Get the the clock gate state for VREF module. -* -* This function will get the clock gate state for VREF module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! -* @brief Enable the clock for LPTIMER module. -* -* This function enables the clock for LPTIMER module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! -* @brief Disable the clock for LPTIMER module. -* -* This function disables the clock for LPTIMER module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! -* @brief Get the the clock gate state for LPTIMER module. -* -* This function will get the clock gate state for LPTIMER module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! -* @brief Enable the clock for RTC module. -* -* This function enables the clock for RTC module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! -* @brief Disable the clock for RTC module. -* -* This function disables the clock for RTC module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! -* @brief Get the the clock gate state for RTC module. -* -* This function will get the clock gate state for RTC module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! -* @brief Enable the clock for DAC module. -* -* This function enables the clock for DAC module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDac0); -} - -/*! -* @brief Disable the clock for DAC module. -* -* This function disables the clock for DAC module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDac0); -} - -/*! -* @brief Get the the clock gate state for DAC module. -* -* This function will get the clock gate state for DAC module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDac0); -} - -/*! -* @brief Enable the clock for SPI module. -* -* This function enables the clock for SPI module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! -* @brief Disable the clock for SPI module. -* -* This function disables the clock for SPI module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for SPI module. -* -* This function will get the clock gate state for SPI module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for I2C module. -* -* This function enables the clock for I2C module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! -* @brief Disable the clock for I2C module. -* -* This function disables the clock for I2C module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for I2C module. -* -* This function will get the clock gate state for I2C module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for LPUART module. -* -* This function enables the clock for LPUART module. -* @param instance module device instance -*/ -void CLOCK_SYS_EnableLpuartClock(uint32_t instance); - -/*! -* @brief Disable the clock for LPUART module. -* -* This function disables the clock for LPUART module. -* @param instance module device instance -*/ -void CLOCK_SYS_DisableLpuartClock(uint32_t instance); - -/*! -* @brief Get the the clock gate state for LPUART module. -* -* This function will get the clock gate state for LPUART module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -bool CLOCK_SYS_GetLpuartGateCmd(uint32_t instance); - -/*! -* @brief Enable the clock for UART module. -* -* This function enables the clock for UART module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUart2); -} - -/*! -* @brief Disable the clock for UART module. -* -* This function disables the clock for UART module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUart2); -} - -/*! -* @brief Get the the clock gate state for UART module. -* -* This function will get the clock gate state for UART module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM,kSimClockGateUart2); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! -* @brief Enable the clock for FLEXIO module. -* -* This function enables the clock for FLEXIO module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_EnableFlexioClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexio0); -} - -/*! -* @brief Disable the clock for FLEXIO module. -* -* This function disables the clock for FLEXIO module. -* @param instance module device instance -*/ -static inline void CLOCK_SYS_DisableFlexioClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexio0); -} - -/*! -* @brief Get the clock gate state for FLEXIO module. -* -* This function will get the clock gate state for FLEXIO module. -* @param instance module device instance -* @return state true - ungated(Enabled), false - gated (Disabled) -*/ -static inline bool CLOCK_SYS_GetFlexioGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM,kSimClockGateFlexio0); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for TPM module. - * - * This function enables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableTpmClock(uint32_t instance); - -/*! - * @brief Disable the clock for TPM module. - * - * This function disables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableTpmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for TPM module. - * - * This function will get the clock gate state for TPM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Set the TPM external clock frequency(TPM_CLKx). - * - * This function sets the TPM external clock frequency (TPM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetTpmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < TPM_EXT_CLK_COUNT); - - g_tpmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - - -#endif /* __FSL_CLOCK_MKL43Z4__H__ */ -/******************************************************************************* -* EOF -******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL46Z4/fsl_clock_MKL46Z4.c b/KSDK_1.2.0/platform/system/src/clock/MKL46Z4/fsl_clock_MKL46Z4.c deleted file mode 100755 index 5dd24cc..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL46Z4/fsl_clock_MKL46Z4.c +++ /dev/null @@ -1,1012 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" -#include "fsl_mcg_hal.h" -#include "fsl_clock_manager.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; /* TPM_CLK */ -#if FSL_FEATURE_SOC_USB_COUNT -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -#endif - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - 0U, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - - CLOCK_HAL_SetOutDiv(SIM, 2U, 0U, 0U, 5U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - - /*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the systen clock frequency. - * This function gets the systen clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - freq >>= 1U; /* divided by 2 for special divider */ - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return CLOCK_SYS_GetExternalRefClock32kFreq() >> 15U; - } - else - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCopFreq - * Description : Gets COP clock frequency. - * This function gets the COP clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCopFreq(uint32_t instance, clock_cop_src_t copSrc) -{ - if (kClockCopSrcLpoClk == copSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcFreq - * Description : Gets rtc clock frequency. - * This function gets rtc clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmfFreq - * Description : Gets the clock frequency for TPM module. - * This function gets the clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance) -{ - uint32_t freq; - clock_tpm_src_t src; - - src = CLOCK_HAL_GetTpmSrc(SIM, instance); - - switch(src) - { - case kClockTpmSrcPllFllSel: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTpmSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTpmSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmExternalFreq - * Description : Gets the external clock frequency for TPM module. - * This function gets the external clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance) -{ - sim_tpm_clk_sel_t src = CLOCK_SYS_GetTpmExternalSrc(instance); - - if (kSimTpmClkSel0 == src) - { - return g_tpmClkFreq[0]; - } - else - { - return g_tpmClkFreq[1]; - } -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - return freq; - } -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpifFreq - * Description : Gets the clock frequency for SPI module. - * This function gets the clock frequency for SPI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetBusClockFreq(); /* BUS CLOCK */ - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); /* SYSTEM CLOCK*/ - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cfFreq - * Description : Gets the clock frequency for I2C module. - * This function gets the clock frequency for I2C moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetBusClockFreq(); /* BUS CLOCK */ - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); /* SYSTEM CLOCK*/ - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLpsciFreq - * Description : Gets the clock frequency for LPSCI module. - * This function gets the clock frequency for LPSCI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpsciFreq(uint32_t instance) -{ - uint32_t freq; - clock_lpsci_src_t src; - - src = CLOCK_HAL_GetLpsciSrc(SIM, instance); - - switch(src) - { - case kClockLpsciSrcPllFllSel: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockLpsciSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpsciSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq = 0; - - switch (instance) - { - case 0: - case 1: - case 2: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Lpsci instance table. */ -static const sim_clock_gate_name_t lpsciGateTable[] = -{ - kSimClockGateLpsci0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableLpsciClock - * Description : Enable the clock for LPSCI module - * This function disable the clock for LPSCI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableLpsciClock(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - SIM_HAL_DisableClock(SIM, lpsciGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetLpsciGateCmd - * Description : Get the the clock gate state for LPSCI module - * This function will get the clock gate state for LPSCI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetLpsciGateCmd(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, lpsciGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableLpsciClock - * Description : Enable the clock for LPSCI module - * This function enables the clock for LPSCI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableLpsciClock(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - SIM_HAL_EnableClock(SIM, lpsciGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - (sim_clock_gate_name_t)(-1), - kSimClockGateUart1, - kSimClockGateUart2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t tpmGateTable[] = -{ - kSimClockGateTpm0, - kSimClockGateTpm1, - kSimClockGateTpm2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableTpmClock - * Description : Enable the clock for TPM module - * This function enables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_EnableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableTpmClock - * Description : Disable the clock for TPM module - * This function disables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_DisableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmGateCmd - * Description : Get the the clock gate state for TPM module - * This function will get the clock gate state for TPM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, tpmGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKL46Z4/fsl_clock_MKL46Z4.h b/KSDK_1.2.0/platform/system/src/clock/MKL46Z4/fsl_clock_MKL46Z4.h deleted file mode 100644 index 58b44b5..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKL46Z4/fsl_clock_MKL46Z4.h +++ /dev/null @@ -1,1237 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KL46Z4_H__) -#define __FSL_CLOCK_KL46Z4_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kl46z4 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief TPM external clock source count. */ -#define TPM_EXT_CLK_COUNT 2 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 - -/*! @brief TPM external clock frequency(TPM_CLK). */ -extern uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -#endif - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kl46z4_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the COP clock frequency. - * - * This function gets the COP clock frequency. - * - * @param instance module device instance - * @param copSrc COP clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetCopFreq(uint32_t instance, clock_cop_src_t copSrc); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets TPM clock frequency. - * - * This function gets the TPM clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance); - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param instance IP instance. - * @param tpmSrc The value to set. - */ -static inline void CLOCK_SYS_SetTpmSrc(uint32_t instance, clock_tpm_src_t tpmSrc) -{ - CLOCK_HAL_SetTpmSrc(SIM, instance, tpmSrc); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_SYS_GetTpmSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTpmSrc(SIM, instance); -} - -/*! - * @brief Get the TPM external clock source frequency. - * - * This function gets the TPM external clock source frequency. - * - * @param instance IP instance. - * @return TPM external clock frequency. - */ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance); - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @param src TPM external clock source. - */ -static inline void CLOCK_SYS_SetTpmExternalSrc(uint32_t instance, sim_tpm_clk_sel_t src) -{ - SIM_HAL_SetTpmExternalClkPinSelMode(SIM, instance, src); -} - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @return setting Current TPM external clock source. - */ -static inline sim_tpm_clk_sel_t CLOCK_SYS_GetTpmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @param usbfsSrc The value to set. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance); - - /*! - * @brief Gets the clock frequency for LPSCI module. - * - * This function gets the clock frequency for LPSCI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpsciFreq(uint32_t instance); - -/*! - * @brief Set the LPSCI clock source selection. - * - * This function sets the LPSCI clock source selection. - * - * @param instance IP instance. - * @param lpsciSrc The value to set. - */ -static inline void CLOCK_SYS_SetLpsciSrc(uint32_t instance, clock_lpsci_src_t lpsciSrc) -{ - CLOCK_HAL_SetLpsciSrc(SIM, instance, lpsciSrc); -} - -/*! - * @brief Get the LPSCI clock source selection. - * - * This function gets the LPSCI clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_lpsci_src_t CLOCK_SYS_GetLpsciSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpsciSrc(SIM, instance); -} - -/*! - * @brief Get the UART clock frequency. - * - * This function gets the UART clock frequency. - * - * @param instance IP instance. - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_LCD_COUNT -/*! - * @brief Enable the clock for SLCD module. - * - * This function enables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSlcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Disable the clock for SLCD module. - * - * This function disables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSlcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Get the the clock gate state for SLCD module. - * - * This function will get the clock gate state for SLCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSlcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Gets the frequency for SLCD default clock. - * - * This function gets the frequency for SLCD default clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdDefaultFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets the frequency for SLCD alternate clock. - * - * This function gets the frequency for SLCD alternate clock (ALTSOURCE = 0). - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAltFreq(uint32_t instance) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the frequency for SLCD alternate 2 clock. - * - * This function gets the frequency for SLCD alternate 2 clock (ALTSOURCE = 1). - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAlt2Freq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} -#endif// FSL_FEATURE_SOC_LCD_COUNT - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for TPM module. - * - * This function enables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableTpmClock(uint32_t instance); - -/*! - * @brief Disable the clock for TPM module. - * - * This function disables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableTpmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for TPM module. - * - * This function will get the clock gate state for TPM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for TSI module. - * - * This function enables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTsiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Disable the clock for TSI module. - * - * This function disables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTsiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Get the the clock gate state for TSI module. - * - * This function will get the clock gate state for TSI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTsiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTsi0); -} - - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for LPSCI module. - * - * This function enables the clock for LPSCI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableLpsciClock(uint32_t instance); - -/*! - * @brief Disable the clock for LPSCI module. - * - * This function disables the clock for LPSCI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableLpsciClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for LPSCI module. - * - * This function will get the clock gate state for LPSCI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetLpsciGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Set the TPM external clock frequency(TPM_CLKx). - * - * This function sets the TPM external clock frequency (TPM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetTpmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < TPM_EXT_CLK_COUNT); - - g_tpmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KL46Z4_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKV10Z7/fsl_clock_MKV10Z7.c b/KSDK_1.2.0/platform/system/src/clock/MKV10Z7/fsl_clock_MKV10Z7.c deleted file mode 100755 index 09b9a81..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKV10Z7/fsl_clock_MKV10Z7.c +++ /dev/null @@ -1,806 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - 0U, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetOutDiv5(SIM, simConfig->outdiv5); - CLOCK_HAL_SetOutDiv5ENCmd(SIM, simConfig->outdiv5Enable); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 0U, 0U, 4U); - CLOCK_HAL_SetOutDiv5(SIM, 3U); - CLOCK_HAL_SetOutDiv5ENCmd(SIM, true); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOutdiv5ClockFreq - * Description : Gets the OUTDIV5 output clock for ADC. - * This function gets the the OUTDIV5 output clock for ADC. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOutdiv5ClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv5(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcAltFreq - * Description : Gets the ADC alternate clock frequency. - * This function gets the ADC alternate clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - clock_adc_alt_src_t adcAltClkSel; - uint32_t adcAltClkValue = 0; - - adcAltClkSel = CLOCK_HAL_GetAdcAltClkSrc(SIM, instance); - switch(adcAltClkSel) - { - case 0: - adcAltClkValue = CLOCK_SYS_GetOutdiv5ClockFreq(); /* OUTDIV5 output */ - break; - case 1: - adcAltClkValue = CLOCK_SYS_GetInternalRefClockFreq(); /* MCGIRC output */ - break; - case 2: - adcAltClkValue = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); /* OSCERCLK output */ - break; - default: - adcAltClkValue = 0; - break; - } - return adcAltClkValue; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmFixedFreq - * Description : Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - uint32_t ftmFixedFreq; - clock_ftm_fixedfreq_src_t ftmFixedFreqSel; - ftmFixedFreqSel = (clock_ftm_fixedfreq_src_t)CLOCK_HAL_GetFtmFixFreqClkSrc(SIM); - switch(ftmFixedFreqSel) - { - case kClockFtmClkMcgFfClk: - ftmFixedFreq = CLOCK_HAL_GetFixedFreqClk(MCG); - break; - case kClockFtmClkMcgIrClk: - ftmFixedFreq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockFtmClkOsc0erClk: - ftmFixedFreq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - ftmFixedFreq = 0; - break; - } - return ftmFixedFreq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_HAL_GetInternalRefClk(MCG); /* For KV10Z7, it's MCGIRCLK */ - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG IRC clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 1: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else if (kSimFtmClkSel1 == sel) - { - return g_ftmClkFreq[1]; - } - else - { - return g_ftmClkFreq[2]; - } -} - -/* ----------------------------CLOCK SYS GATE CONTROL--------------------------*/ -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKV10Z7/fsl_clock_MKV10Z7.h b/KSDK_1.2.0/platform/system/src/clock/MKV10Z7/fsl_clock_MKV10Z7.h deleted file mode 100644 index 64de6a9..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKV10Z7/fsl_clock_MKV10Z7.h +++ /dev/null @@ -1,926 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KV10Z7_H__) -#define __FSL_CLOCK_KV10Z7_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kv10z7 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 3 - -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv4, outdiv5; /*!< OUTDIV setting. */ - bool outdiv5Enable; /*!< OUTDIV5EN. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kv10z7_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out divider5 setting(OUTDIV5). - * - * This function sets divide value OUTDIV5. - * - * @param outdiv5 Outdivider5 setting - */ -static inline void CLOCK_SYS_SetOutDiv5(uint8_t outdiv5) -{ - CLOCK_HAL_SetOutDiv5(SIM, outdiv5); -} - -/*! - * @brief Gets the clock out divider5 setting(OUTDIV5). - * - * This function gets divide value OUTDIV5. - * - * @return Outdivider5 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv5(void) -{ - return CLOCK_HAL_GetOutDiv5(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the OUTDIV5 output clock for ADC. - * - * This function gets the OUTDIV5 output clock for ADC. - * - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetOutdiv5ClockFreq(void); - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance); - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KV10Z7_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKV30F12810/fsl_clock_MKV30F12810.c b/KSDK_1.2.0/platform/system/src/clock/MKV30F12810/fsl_clock_MKV30F12810.c deleted file mode 100755 index 33c45e4..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKV30F12810/fsl_clock_MKV30F12810.c +++ /dev/null @@ -1,809 +0,0 @@ -/* - * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - - CLOCK_HAL_SetOutDiv(SIM, 1U, 1U, 0U, 7U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kOsc0ErClockUndiv: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelIrc48M: - freq = CPU_INTERNAL_IRC_48M; - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq - * Description : Gets OSC0ERCLKUDIV. - * This function gets the OSC0 external reference undivided frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq() - >> OSC_HAL_GetExternalRefClkDiv(g_oscBase[0]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG); - } - else - { - return CLOCK_SYS_GetCoreClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClkUndiv: /* OSC0ERCLKUDIV clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKV30F12810/fsl_clock_MKV30F12810.h b/KSDK_1.2.0/platform/system/src/clock/MKV30F12810/fsl_clock_MKV30F12810.h deleted file mode 100644 index 8550d86..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKV30F12810/fsl_clock_MKV30F12810.h +++ /dev/null @@ -1,1119 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KV30F12810_H__) -#define __FSL_CLOCK_KV30F12810_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kv30f12810 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kv30f12810_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets the OSC0ERCLK_UNDIV frequency. - * - * This function gets the undivided OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void); - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets ADC alternate 2 clock frequency. - * - * This function gets the ADC alternate 2 clock frequency (ALTCLK2). - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAlt2Freq(uint32_t instance) -{ - return CPU_INTERNAL_IRC_48M; -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KV30F12810_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKV31F12810/fsl_clock_MKV31F12810.c b/KSDK_1.2.0/platform/system/src/clock/MKV31F12810/fsl_clock_MKV31F12810.c deleted file mode 100755 index 449f397..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKV31F12810/fsl_clock_MKV31F12810.c +++ /dev/null @@ -1,848 +0,0 @@ -/* - * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - - CLOCK_HAL_SetOutDiv(SIM, 1U, 1U, 0U, 7U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kOsc0ErClockUndiv: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kIrc48mClock: - *frequency = CPU_INTERNAL_IRC_48M; - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the systen clock frequency. - * This function gets the systen clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelIrc48M: - freq = CPU_INTERNAL_IRC_48M; - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq - * Description : Gets OSC0ERCLKUDIV. - * This function gets the OSC0 external reference undevided frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq() - >> OSC_HAL_GetExternalRefClkDiv(g_oscBase[0]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG); - } - else - { - return CLOCK_SYS_GetCoreClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx prescaler/glitch filter clock frequency. - * This function gets the LPTMRx prescaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClkUndiv: /* OSC0ERCLKUDIV clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLpuartFreq - * Description : Gets the clock frequency for LPUART module. - * This function gets the clock frequency for LPUART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance) -{ - clock_lpuart_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetLpuartSrc(SIM, instance); - switch (src) - { - case kClockLpuartSrcPllFllSel: - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockLpuartSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpuartSrcMcgIrClk: - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKV31F12810/fsl_clock_MKV31F12810.h b/KSDK_1.2.0/platform/system/src/clock/MKV31F12810/fsl_clock_MKV31F12810.h deleted file mode 100644 index 56524d3..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKV31F12810/fsl_clock_MKV31F12810.h +++ /dev/null @@ -1,1198 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KV31F12810_H__) -#define __FSL_CLOCK_KV31F12810_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kv31f12810 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kv31f12810_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets the OSC0ERCLK_UNDIV frequency. - * - * This function gets the undivided OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void); - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock source for LPUART module - * - * This function gets the clock source for LPUART module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_lpuart_src_t CLOCK_SYS_GetLpuartSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpuartSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for LPUART module - * - * This function sets the clock source for LPUART module. - * @param instance module device instance - * @param lpuartSrc Clock source. - */ -static inline void CLOCK_SYS_SetLpuartSrc(uint32_t instance, clock_lpuart_src_t lpuartSrc) -{ - CLOCK_HAL_SetLpuartSrc(SIM, instance, lpuartSrc); -} - -/*! - * @brief Gets the clock frequency for LPUART module - * - * This function gets the clock frequency for LPUART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets ADC alternate 2 clock frequency. - * - * This function gets the ADC alternate 2 clock frequency (ALTCLK2). - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAlt2Freq(uint32_t instance) -{ - return CPU_INTERNAL_IRC_48M; -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for LPUART module. - * - * This function enables the clock for LPUART module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLpuartClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Disable the clock for LPUART module. - * - * This function disables the clock for LPUART module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLpuartClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Get the the clock gate state for LPUART module. - * - * This function will get the clock gate state for LPUART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLpuartGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KV31F12810_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKV31F25612/fsl_clock_MKV31F25612.c b/KSDK_1.2.0/platform/system/src/clock/MKV31F25612/fsl_clock_MKV31F25612.c deleted file mode 100755 index 154a432..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKV31F25612/fsl_clock_MKV31F25612.c +++ /dev/null @@ -1,854 +0,0 @@ -/* - * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - - CLOCK_HAL_SetOutDiv(SIM, 1U, 3U, 0U, 7U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kOsc0ErClockUndiv: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kIrc48mClock: - *frequency = CPU_INTERNAL_IRC_48M; - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the systen clock frequency. - * This function gets the systen clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockPllFllSelIrc48M: - freq = CPU_INTERNAL_IRC_48M; - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq - * Description : Gets OSC0ERCLKUDIV. - * This function gets the OSC0 external reference undevided frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq() - >> OSC_HAL_GetExternalRefClkDiv(g_oscBase[0]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG); - } - else - { - return CLOCK_SYS_GetCoreClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClkUndiv: /* OSC0ERCLKUDIV clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLpuartFreq - * Description : Gets the clock frequency for LPUART module. - * This function gets the clock frequency for LPUART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance) -{ - clock_lpuart_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetLpuartSrc(SIM, instance); - switch (src) - { - case kClockLpuartSrcPllFllSel: - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockLpuartSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpuartSrcMcgIrClk: - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKV31F25612/fsl_clock_MKV31F25612.h b/KSDK_1.2.0/platform/system/src/clock/MKV31F25612/fsl_clock_MKV31F25612.h deleted file mode 100644 index a3101ab..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKV31F25612/fsl_clock_MKV31F25612.h +++ /dev/null @@ -1,1232 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KV31F25612_H__) -#define __FSL_CLOCK_KV31F25612_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kv31f25612 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kv31f25612_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets the OSC0ERCLK_UNDIV frequency. - * - * This function gets the undivided OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void); - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock source for LPUART module - * - * This function gets the clock source for LPUART module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_lpuart_src_t CLOCK_SYS_GetLpuartSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpuartSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for LPUART module - * - * This function sets the clock source for LPUART module. - * @param instance module device instance - * @param lpuartSrc Clock source. - */ -static inline void CLOCK_SYS_SetLpuartSrc(uint32_t instance, clock_lpuart_src_t lpuartSrc) -{ - CLOCK_HAL_SetLpuartSrc(SIM, instance, lpuartSrc); -} - -/*! - * @brief Gets the clock frequency for LPUART module - * - * This function gets the clock frequency for LPUART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets ADC alternate 2 clock frequency. - * - * This function gets the ADC alternate 2 clock frequency (ALTCLK2). - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAlt2Freq(uint32_t instance) -{ - return CPU_INTERNAL_IRC_48M; -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for LPUART module. - * - * This function enables the clock for LPUART module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLpuartClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Disable the clock for LPUART module. - * - * This function disables the clock for LPUART module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLpuartClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Get the the clock gate state for LPUART module. - * - * This function will get the clock gate state for LPUART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLpuartGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KV31F25612_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKV31F51212/fsl_clock_MKV31F51212.c b/KSDK_1.2.0/platform/system/src/clock/MKV31F51212/fsl_clock_MKV31F51212.c deleted file mode 100755 index b5c1285..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKV31F51212/fsl_clock_MKV31F51212.c +++ /dev/null @@ -1,871 +0,0 @@ -/* - * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - - CLOCK_HAL_SetOutDiv(SIM, 1U, 3U, 3U, 7U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlexBusClock: - *frequency = CLOCK_SYS_GetFlexbusFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kOsc0ErClockUndiv: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kIrc48mClock: - *frequency = CPU_INTERNAL_IRC_48M; - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the systen clock frequency. - * This function gets the systen clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexbusFreq - * Description : Gets the clock frequency for FLEXBUS module - * This function gets the clock frequency for FLEXBUS moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexbusFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv3(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockPllFllSelIrc48M: - freq = CPU_INTERNAL_IRC_48M; - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq - * Description : Gets OSC0ERCLKUDIV. - * This function gets the OSC0 external reference undevided frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq() - >> OSC_HAL_GetExternalRefClkDiv(g_oscBase[0]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG); - } - else - { - return CLOCK_SYS_GetCoreClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClkUndiv: /* OSC0ERCLKUDIV clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLpuartFreq - * Description : Gets the clock frequency for LPUART module. - * This function gets the clock frequency for LPUART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance) -{ - clock_lpuart_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetLpuartSrc(SIM, instance); - switch (src) - { - case kClockLpuartSrcPllFllSel: - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockLpuartSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpuartSrcMcgIrClk: - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0, - kSimClockGateAdc1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0, - kSimClockGateDac1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, - kSimClockGateFtm3 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKV31F51212/fsl_clock_MKV31F51212.h b/KSDK_1.2.0/platform/system/src/clock/MKV31F51212/fsl_clock_MKV31F51212.h deleted file mode 100644 index 8cb88c2..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKV31F51212/fsl_clock_MKV31F51212.h +++ /dev/null @@ -1,1299 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KV31F51212_H__) -#define __FSL_CLOCK_KV31F51212_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kv31f51212 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kv31f51212_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider3 setting(OUTDIV3). - * - * This function sets divide value OUTDIV3. - * - * @param outdiv3 Outdivider3 setting - */ -static inline void CLOCK_SYS_SetOutDiv3(uint8_t outdiv3) -{ - CLOCK_HAL_SetOutDiv3(SIM, outdiv3); -} - -/*! - * @brief Gets the clock out divider3 setting(OUTDIV3). - * - * This function gets divide value OUTDIV3. - * - * @return Outdivider3 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv3(void) -{ - return CLOCK_HAL_GetOutDiv3(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets the OSC0ERCLK_UNDIV frequency. - * - * This function gets the undivided OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void); - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock source for LPUART module - * - * This function gets the clock source for LPUART module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_lpuart_src_t CLOCK_SYS_GetLpuartSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpuartSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for LPUART module - * - * This function sets the clock source for LPUART module. - * @param instance module device instance - * @param lpuartSrc Clock source. - */ -static inline void CLOCK_SYS_SetLpuartSrc(uint32_t instance, clock_lpuart_src_t lpuartSrc) -{ - CLOCK_HAL_SetLpuartSrc(SIM, instance, lpuartSrc); -} - -/*! - * @brief Gets the clock frequency for LPUART module - * - * This function gets the clock frequency for LPUART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets ADC alternate 2 clock frequency. - * - * This function gets the ADC alternate 2 clock frequency (ALTCLK2). - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAlt2Freq(uint32_t instance) -{ - return CPU_INTERNAL_IRC_48M; -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Enable the clock for FLEXBUS module. - * - * This function enables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexbusClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Disable the clock for FLEXBUS module. - * - * This function disables the clock for FLEXBUS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexbusClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Get the the clock gate state for FLEXBUS module. - * - * This function will get the clock gate state for FLEXBUS module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexbusGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFlexbus0); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for LPUART module. - * - * This function enables the clock for LPUART module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLpuartClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Disable the clock for LPUART module. - * - * This function disables the clock for LPUART module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLpuartClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Get the the clock gate state for LPUART module. - * - * This function will get the clock gate state for LPUART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLpuartGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLpuart0); -} - -/*! - * @brief Set the FTM external clock frequency(FTM_CLKx). - * - * This function sets the FTM external clock frequency (FTM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetFtmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < FTM_EXT_CLK_COUNT); - - g_ftmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KV31F51212_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKV40F15/fsl_clock_MKV40F15.c b/KSDK_1.2.0/platform/system/src/clock/MKV40F15/fsl_clock_MKV40F15.c deleted file mode 100755 index 0412a4a..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKV40F15/fsl_clock_MKV40F15.c +++ /dev/null @@ -1,765 +0,0 @@ -/* - * Copyright (c) 2014 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_osc_hal.h" -#include "fsl_clock_manager.h" -#include "fsl_mcg_hal_modes.h" -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/* Table of base addresses for instances. */ -extern SIM_Type * const g_simBase[]; -extern MCG_Type * const g_mcgBase[]; - -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - -/******************************************************************************* - * Code - ******************************************************************************/ -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDmaFreq - * Description : Gets the clock frequency for DMA module - * This function gets the clock frequency for DMA moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetDmaFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kSystemClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDmamuxFreq - * Description : Gets the clock frequency for DMAMUX module - * This function gets the clock frequency for DMAMUX moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetDmamuxFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFreq - * Description : Gets the clock frequency for PORT module - * This function gets the clock frequency for PORT moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kLpoClock, &freq); - return freq; -} -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*! @brief CLOCK name config table for KV46*/ -const clock_name_config_t kClockNameConfigTable [] = { - {false, kSystemClock, kClockDividerOutdiv1}, /* Core clock divider */ - {false, kSystemClock, kClockDividerOutdiv1}, /* System clock divider */ - {false, kSystemClock, kClockDividerOutdiv1}, /* Not used for KV4x */ - {false, kSystemClock, kClockDividerOutdiv4}, /* Bus clock divider */ - {false, kSystemClock, kClockDividerOutdiv1}, /* Not used for KV4x*/ - {false, kSystemClock, kClockDividerOutdiv4}, /* Flash clock divider */ - {false, kSystemClock, kClockDividerOutdiv2} /* Fast peripheral clock divider */ -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSysClkFreq - * Description : Internal function to get the system clock frequency - * This function will check the clock name configuration table for specific - * chip family and find out the supported clock name for that chip family - * then it will call the mcg hal function to get the basic system clock, - * calculate the clock frequency for specified clock name. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_GetSysClkFreq(clock_names_t clockName, - uint32_t *frequency) -{ - const clock_name_config_t *table = &kClockNameConfigTable[clockName]; - - /* check if we need to use a reference clock*/ - if (table->useOtherRefClock) - { - /* get other specified ref clock*/ - if ( kClockManagerSuccess != CLOCK_SYS_GetFreq(table->otherRefClockName, - frequency) ) - { - return kClockManagerNoSuchClockName; - } - else - { - return kClockManagerSuccess; - } - } - else - { - /* get default ref clock */ - if ((table->dividerName)==kClockDividerOutdiv1) - { - *frequency =(CLOCK_HAL_GetOutClk(g_mcgBase[0])/(CLOCK_HAL_GetOutDiv1(SIM) + 1)); - } - else if ((table->dividerName)==kClockDividerOutdiv2) - { - *frequency =(CLOCK_HAL_GetOutClk(g_mcgBase[0])/(CLOCK_HAL_GetOutDiv2(SIM) + 1)); - } - else if ((table->dividerName)==kClockDividerOutdiv4) - { - *frequency =(CLOCK_HAL_GetOutClk(g_mcgBase[0])/(CLOCK_HAL_GetOutDiv4(SIM) + 1)); - } - return kClockManagerSuccess; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 2U, 5U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kFastPeripheralClock: - returnCode = CLOCK_SYS_GetSysClkFreq(clockName, frequency); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kOsc0ErClockUndiv: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; -#if FSL_FEATURE_MCG_HAS_IRC_48M - case kIrc48mClock: - *frequency = CPU_INTERNAL_IRC_48M; - break; -#endif - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the systen clock frequency. - * This function gets the systen clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFastPeripheralClockFreq - * Description : Gets the fast peripheral clock frequency. - * This function gets the fast peripheral clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFastPeripheralClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq() - >> OSC_HAL_GetExternalRefClkDiv(g_oscBase[0]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq - * Description : Gets OSC0ERCLKUDIV. - * This function gets the OSC0 external reference undivided frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx prescaler/glitch filter clock frequency. - * This function gets the LPTMRx prescaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClkUndiv: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEwmFreq - * Description : Gets the clock frequency for Ewm module - * This function gets the clock frequency for Ewm moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kLpoClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtfFreq - * Description : Gets the clock frequency for FTF module. (Flash Memory) - * This function gets the clock frequency for FTF moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFlashClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCrcFreq - * Description : Gets the clock frequency for CRC module - * This function gets the clock frequency for CRC moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kSystemClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcFreq - * Description : Gets the clock frequency for ADC module - * This function gets the clock frequency for ADC moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetAdcFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kMcgIrClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCmpFreq - * Description : Gets the clock frequency for CMP module - * This function gets the clock frequency for CMP moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPdbFreq - * Description : Gets the clock frequency for PDB module - * This function gets the clock frequency for PDB moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPwmFreq - * Description : Gets the clock frequency for eFlexPWM module - * This function gets the clock frequency for eFlexPWM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPwmFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPitFreq - * Description : Gets the clock frequency for Pit module. - * This function gets the clock frequency for Pit moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiFreq - * Description : Gets the clock frequency for SPI module. - * This function gets the clock frequency for SPI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cFreq - * Description : Gets the clock frequency for I2C module. - * This function gets the clock frequency for I2C moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetGpioFreq - * Description : Gets the clock frequency for GPIO module. - * This function gets the clock frequency for GPIO moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kSystemClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEncFreq - * Description : Gets the clock frequency for ENC module. - * This function gets the clock frequency for ENC moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEncFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetXbarFreq - * Description : Gets the clock frequency for XBAR module. - * This function gets the clock frequency for XBAR moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetXbarFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAoiFreq - * Description : Gets the clock frequency for AOI module. - * This function gets the clock frequency for AOI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetAoiFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanFreq - * Description : Gets FLEXCAN clock frequency. - * This function gets the FLEXCAN clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint8_t instance, clock_flexcan_src_t flexcanSrc) -{ - uint32_t freq = 0; - if (kClockFlexcanSrcOsc0erClk == flexcanSrc) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } - else - { - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; - } -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKV40F15/fsl_clock_MKV40F15.h b/KSDK_1.2.0/platform/system/src/clock/MKV40F15/fsl_clock_MKV40F15.h deleted file mode 100644 index dbad983..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKV40F15/fsl_clock_MKV40F15.h +++ /dev/null @@ -1,1267 +0,0 @@ -/* - * Copyright (c) 2014 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KV40F15_H__) -#define __FSL_CLOCK_KV40F15_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -#define FTM_EXT_CLK_COUNT 2 /* FTM external clock source count. */ - -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK */ - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -} sim_config_t; - -/*! @brief Clock name configuration table structure*/ -typedef struct ClockNameConfig { - bool useOtherRefClock; /*!< if it uses the other ref clock*/ - clock_names_t otherRefClockName; /*!< other ref clock name*/ - clock_divider_names_t dividerName; /*!< clock divider name*/ -} clock_name_config_t; - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the fast peripheral clock frequency. - * - * This function gets the fast peripheral clock frequency. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetFastPeripheralClockFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selecton of ERCLK32K. - * - * This function sets the clock selecton of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selecton of ERCLK32K. - * - * This function gets the clock selecton of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets the OSC0ERCLK_UNDIV frequency. - * - * This function gets the undivided OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void); - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for DMA module. - * - * This function gets the clock frequence for DMA moudle. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetDmaFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for DMAMUX module. - * - * This function gets the clock frequence for DMAMUX moudle. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetDmamuxFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequence for EWM moudle. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequence for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequence for CRC module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for ADC module. - * - * This function gets the clock frequence for ADC module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetAdcFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequence for CMP module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance); - -/*! - * @brief Gets the frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequence for PDB module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for eFlexPWM module. - * - * This function gets the clock frequence for eFlexPWM module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetPwmFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFastPeripheralClockFreq(); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequence for PIT module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequence for SPI module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequence for I2C module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequence for UART module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequence for GPIO module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for ENC module - * - * This function gets the clock frequence for ENC module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetEncFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for XBAR module - * - * This function gets the clock frequence for XBAR module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetXbarFreq(uint32_t instance); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets the clock frequency for AOI module - * - * This function gets the clock frequence for AOI module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetAoiFreq(uint32_t instance); - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableDmaClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableDmaClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetDmaGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableDmamuxClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableDmamuxClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetDmamuxGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableEwmClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableEwmClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetEwmGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableFtfClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableFtfClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetFtfGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableCrcClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableCrcClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetCrcGateCmd(g_simBase[0], instance); -} - - - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - SIM_HAL_EnableAdcClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - SIM_HAL_DisableAdcClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetAdcGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableCmpClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableCmpClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetCmpGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - SIM_HAL_EnableDacClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - SIM_HAL_DisableDacClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - return SIM_HAL_GetDacGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnablePdbClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisablePdbClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetPdbGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - SIM_HAL_EnableFtmClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - SIM_HAL_DisableFtmClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetFtmGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnablePitClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisablePitClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetPitGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableLptmrClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableLptmrClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetLptmrGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexcanClock(uint32_t instance) -{ - SIM_HAL_EnableFlexcanClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexcanClock(uint32_t instance) -{ - SIM_HAL_DisableFlexcanClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance) -{ - return SIM_HAL_GetFlexcanGateCmd(g_simBase[0], instance); -} - - /*! - * @brief Gets FLEXCAN clock frequency. - * - * This function gets the FLEXCAN clock frequency. - * - * @param instance module device instance - * @param flexcanSrc clock source - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint8_t instance, clock_flexcan_src_t flexcanSrc); - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - SIM_HAL_EnableSpiClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - SIM_HAL_DisableSpiClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetSpiGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - SIM_HAL_EnableI2cClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - SIM_HAL_DisableI2cClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - return SIM_HAL_GetI2cGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - SIM_HAL_EnableUartClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - SIM_HAL_DisableUartClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - return SIM_HAL_GetUartGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for eFlexPWM module. - * - * This function enables the clock for eFlexPWM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePwmClock(uint32_t instance) -{ - SIM_HAL_EnablePwmClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for eFlexPWM module. - * - * This function disables the clock for eFlexPWM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePwmClock(uint32_t instance) -{ - SIM_HAL_DisablePwmClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for eFlexPWM module. - * - * This function will get the clock gate state for eFlexPWM moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetPwmGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for AOI module. - * - * This function enables the clock for AOI moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableAoiClock(uint32_t instance) -{ - SIM_HAL_EnableAoiClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for AOI module. - * - * This function disables the clock for AOI moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableAoiClock(uint32_t instance) -{ - SIM_HAL_DisableAoiClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for AOI module. - * - * This function will get the clock gate state for AOI moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetAoiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetAoiGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for XBAR module. - * - * This function enables the clock for XBAR moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableXbarClock(uint32_t instance) -{ - SIM_HAL_EnableXbarClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for XBAR module. - * - * This function disables the clock for XBAR moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableXbarClock(uint32_t instance) -{ - SIM_HAL_DisableXbarClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for XBAR module. - * - * This function will get the clock gate state for XBAR moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetXbarGateCmd(uint32_t instance) -{ - return SIM_HAL_GetXbarGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for ENC module. - * - * This function enables the clock for ENC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEncClock(uint32_t instance) -{ - SIM_HAL_EnableEncClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for ENC module. - * - * This function disables the clock for ENC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEncClock(uint32_t instance) -{ - SIM_HAL_DisableEncClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for ENC module. - * - * This function will get the clock gate state for ENC moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEncGateCmd(uint32_t instance) -{ - return SIM_HAL_GetEncGateCmd(g_simBase[0], instance); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KV40F15_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKV43F15/fsl_clock_MKV43F15.c b/KSDK_1.2.0/platform/system/src/clock/MKV43F15/fsl_clock_MKV43F15.c deleted file mode 100755 index 9d76fd3..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKV43F15/fsl_clock_MKV43F15.c +++ /dev/null @@ -1,765 +0,0 @@ -/* - * Copyright (c) 2014 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_osc_hal.h" -#include "fsl_clock_manager.h" -#include "fsl_mcg_hal_modes.h" -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/* Table of base addresses for instances. */ -extern SIM_Type * const g_simBase[]; -extern MCG_Type * const g_mcgBase[]; - -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - -/******************************************************************************* - * Code - ******************************************************************************/ -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDmaFreq - * Description : Gets the clock frequency for DMA module - * This function gets the clock frequency for DMA moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetDmaFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kSystemClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDmamuxFreq - * Description : Gets the clock frequency for DMAMUX module - * This function gets the clock frequency for DMAMUX moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetDmamuxFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFreq - * Description : Gets the clock frequency for PORT module - * This function gets the clock frequency for PORT moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kLpoClock, &freq); - return freq; -} -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*! @brief CLOCK name config table for KV46*/ -const clock_name_config_t kClockNameConfigTable [] = { - {false, kSystemClock, kClockDividerOutdiv1}, /* Core clock divider */ - {false, kSystemClock, kClockDividerOutdiv1}, /* System clock divider */ - {false, kSystemClock, kClockDividerOutdiv1}, /* Not used for KV4x */ - {false, kSystemClock, kClockDividerOutdiv4}, /* Bus clock divider */ - {false, kSystemClock, kClockDividerOutdiv1}, /* Not used for KV4x*/ - {false, kSystemClock, kClockDividerOutdiv4}, /* Flash clock divider */ - {false, kSystemClock, kClockDividerOutdiv2} /* Fast peripheral clock divider */ -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSysClkFreq - * Description : Internal function to get the system clock frequency - * This function will check the clock name configuration table for specific - * chip family and find out the supported clock name for that chip family - * then it will call the mcg hal function to get the basic system clock, - * calculate the clock frequency for specified clock name. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_GetSysClkFreq(clock_names_t clockName, - uint32_t *frequency) -{ - const clock_name_config_t *table = &kClockNameConfigTable[clockName]; - - /* check if we need to use a reference clock*/ - if (table->useOtherRefClock) - { - /* get other specified ref clock*/ - if ( kClockManagerSuccess != CLOCK_SYS_GetFreq(table->otherRefClockName, - frequency) ) - { - return kClockManagerNoSuchClockName; - } - else - { - return kClockManagerSuccess; - } - } - else - { - /* get default ref clock */ - if ((table->dividerName)==kClockDividerOutdiv1) - { - *frequency =(CLOCK_HAL_GetOutClk(g_mcgBase[0])/(CLOCK_HAL_GetOutDiv1(SIM) + 1)); - } - else if ((table->dividerName)==kClockDividerOutdiv2) - { - *frequency =(CLOCK_HAL_GetOutClk(g_mcgBase[0])/(CLOCK_HAL_GetOutDiv2(SIM) + 1)); - } - else if ((table->dividerName)==kClockDividerOutdiv4) - { - *frequency =(CLOCK_HAL_GetOutClk(g_mcgBase[0])/(CLOCK_HAL_GetOutDiv4(SIM) + 1)); - } - return kClockManagerSuccess; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 2U, 5U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kFastPeripheralClock: - returnCode = CLOCK_SYS_GetSysClkFreq(clockName, frequency); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kOsc0ErClockUndiv: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; -#if FSL_FEATURE_MCG_HAS_IRC_48M - case kIrc48mClock: - *frequency = CPU_INTERNAL_IRC_48M; - break; -#endif - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the systen clock frequency. - * This function gets the systen clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFastPeripheralClockFreq - * Description : Gets the fast peripheral clock frequency. - * This function gets the fast peripheral clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFastPeripheralClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq() - >> OSC_HAL_GetExternalRefClkDiv(g_oscBase[0]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq - * Description : Gets OSC0ERCLKUDIV. - * This function gets the OSC0 external reference undivided frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx prescaler/glitch filter clock frequency. - * This function gets the LPTMRx prescaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClkUndiv: /* OSCERCLK_UNDIV clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEwmFreq - * Description : Gets the clock frequency for Ewm module - * This function gets the clock frequency for Ewm moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kLpoClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtfFreq - * Description : Gets the clock frequency for FTF module. (Flash Memory) - * This function gets the clock frequency for FTF moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFlashClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCrcFreq - * Description : Gets the clock frequency for CRC module - * This function gets the clock frequency for CRC moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kSystemClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcFreq - * Description : Gets the clock frequency for ADC module - * This function gets the clock frequency for ADC moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetAdcFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kMcgIrClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCmpFreq - * Description : Gets the clock frequency for CMP module - * This function gets the clock frequency for CMP moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPdbFreq - * Description : Gets the clock frequency for PDB module - * This function gets the clock frequency for PDB moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPwmFreq - * Description : Gets the clock frequency for eFlexPWM module - * This function gets the clock frequency for eFlexPWM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPwmFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPitFreq - * Description : Gets the clock frequency for Pit module. - * This function gets the clock frequency for Pit moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiFreq - * Description : Gets the clock frequency for SPI module. - * This function gets the clock frequency for SPI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cFreq - * Description : Gets the clock frequency for I2C module. - * This function gets the clock frequency for I2C moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetGpioFreq - * Description : Gets the clock frequency for GPIO module. - * This function gets the clock frequency for GPIO moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kSystemClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEncFreq - * Description : Gets the clock frequency for ENC module. - * This function gets the clock frequency for ENC moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEncFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetXbarFreq - * Description : Gets the clock frequency for XBAR module. - * This function gets the clock frequency for XBAR moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetXbarFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAoiFreq - * Description : Gets the clock frequency for AOI module. - * This function gets the clock frequency for AOI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetAoiFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanFreq - * Description : Gets FLEXCAN clock frequency. - * This function gets the FLEXCAN clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint8_t instance, clock_flexcan_src_t flexcanSrc) -{ - uint32_t freq = 0; - if (kClockFlexcanSrcOsc0erClk == flexcanSrc) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } - else - { - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; - } -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKV43F15/fsl_clock_MKV43F15.h b/KSDK_1.2.0/platform/system/src/clock/MKV43F15/fsl_clock_MKV43F15.h deleted file mode 100644 index 6f0d4c8..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKV43F15/fsl_clock_MKV43F15.h +++ /dev/null @@ -1,1267 +0,0 @@ -/* - * Copyright (c) 2014 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KV43F15_H__) -#define __FSL_CLOCK_KV43F15_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -#define FTM_EXT_CLK_COUNT 2 /* FTM external clock source count. */ - -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK */ - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -} sim_config_t; - -/*! @brief Clock name configuration table structure*/ -typedef struct ClockNameConfig { - bool useOtherRefClock; /*!< if it uses the other ref clock*/ - clock_names_t otherRefClockName; /*!< other ref clock name*/ - clock_divider_names_t dividerName; /*!< clock divider name*/ -} clock_name_config_t; - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the fast peripheral clock frequency. - * - * This function gets the fast peripheral clock frequency. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetFastPeripheralClockFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selecton of ERCLK32K. - * - * This function sets the clock selecton of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selecton of ERCLK32K. - * - * This function gets the clock selecton of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets the OSC0ERCLK_UNDIV frequency. - * - * This function gets the undivided OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void); - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for DMA module. - * - * This function gets the clock frequence for DMA moudle. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetDmaFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for DMAMUX module. - * - * This function gets the clock frequence for DMAMUX moudle. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetDmamuxFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequence for EWM moudle. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequence for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequence for CRC module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for ADC module. - * - * This function gets the clock frequence for ADC module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetAdcFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequence for CMP module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance); - -/*! - * @brief Gets the frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequence for PDB module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for eFlexPWM module. - * - * This function gets the clock frequence for eFlexPWM module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetPwmFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFastPeripheralClockFreq(); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequence for PIT module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequence for SPI module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequence for I2C module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequence for UART module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequence for GPIO module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for ENC module - * - * This function gets the clock frequence for ENC module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetEncFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for XBAR module - * - * This function gets the clock frequence for XBAR module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetXbarFreq(uint32_t instance); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets the clock frequency for AOI module - * - * This function gets the clock frequence for AOI module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetAoiFreq(uint32_t instance); - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableDmaClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableDmaClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetDmaGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableDmamuxClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableDmamuxClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetDmamuxGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableEwmClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableEwmClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetEwmGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableFtfClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableFtfClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetFtfGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableCrcClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableCrcClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetCrcGateCmd(g_simBase[0], instance); -} - - - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - SIM_HAL_EnableAdcClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - SIM_HAL_DisableAdcClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetAdcGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableCmpClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableCmpClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetCmpGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - SIM_HAL_EnableDacClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - SIM_HAL_DisableDacClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - return SIM_HAL_GetDacGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnablePdbClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisablePdbClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetPdbGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - SIM_HAL_EnableFtmClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - SIM_HAL_DisableFtmClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetFtmGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnablePitClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisablePitClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetPitGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableLptmrClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableLptmrClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetLptmrGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexcanClock(uint32_t instance) -{ - SIM_HAL_EnableFlexcanClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexcanClock(uint32_t instance) -{ - SIM_HAL_DisableFlexcanClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance) -{ - return SIM_HAL_GetFlexcanGateCmd(g_simBase[0], instance); -} - - /*! - * @brief Gets FLEXCAN clock frequency. - * - * This function gets the FLEXCAN clock frequency. - * - * @param instance module device instance - * @param flexcanSrc clock source - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint8_t instance, clock_flexcan_src_t flexcanSrc); - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - SIM_HAL_EnableSpiClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - SIM_HAL_DisableSpiClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetSpiGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - SIM_HAL_EnableI2cClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - SIM_HAL_DisableI2cClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - return SIM_HAL_GetI2cGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - SIM_HAL_EnableUartClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - SIM_HAL_DisableUartClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - return SIM_HAL_GetUartGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for eFlexPWM module. - * - * This function enables the clock for eFlexPWM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePwmClock(uint32_t instance) -{ - SIM_HAL_EnablePwmClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for eFlexPWM module. - * - * This function disables the clock for eFlexPWM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePwmClock(uint32_t instance) -{ - SIM_HAL_DisablePwmClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for eFlexPWM module. - * - * This function will get the clock gate state for eFlexPWM moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetPwmGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for AOI module. - * - * This function enables the clock for AOI moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableAoiClock(uint32_t instance) -{ - SIM_HAL_EnableAoiClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for AOI module. - * - * This function disables the clock for AOI moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableAoiClock(uint32_t instance) -{ - SIM_HAL_DisableAoiClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for AOI module. - * - * This function will get the clock gate state for AOI moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetAoiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetAoiGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for XBAR module. - * - * This function enables the clock for XBAR moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableXbarClock(uint32_t instance) -{ - SIM_HAL_EnableXbarClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for XBAR module. - * - * This function disables the clock for XBAR moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableXbarClock(uint32_t instance) -{ - SIM_HAL_DisableXbarClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for XBAR module. - * - * This function will get the clock gate state for XBAR moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetXbarGateCmd(uint32_t instance) -{ - return SIM_HAL_GetXbarGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for ENC module. - * - * This function enables the clock for ENC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEncClock(uint32_t instance) -{ - SIM_HAL_EnableEncClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for ENC module. - * - * This function disables the clock for ENC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEncClock(uint32_t instance) -{ - SIM_HAL_DisableEncClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for ENC module. - * - * This function will get the clock gate state for ENC moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEncGateCmd(uint32_t instance) -{ - return SIM_HAL_GetEncGateCmd(g_simBase[0], instance); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KV43F15_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKV44F15/fsl_clock_MKV44F15.c b/KSDK_1.2.0/platform/system/src/clock/MKV44F15/fsl_clock_MKV44F15.c deleted file mode 100755 index 9d76fd3..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKV44F15/fsl_clock_MKV44F15.c +++ /dev/null @@ -1,765 +0,0 @@ -/* - * Copyright (c) 2014 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_osc_hal.h" -#include "fsl_clock_manager.h" -#include "fsl_mcg_hal_modes.h" -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/* Table of base addresses for instances. */ -extern SIM_Type * const g_simBase[]; -extern MCG_Type * const g_mcgBase[]; - -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - -/******************************************************************************* - * Code - ******************************************************************************/ -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDmaFreq - * Description : Gets the clock frequency for DMA module - * This function gets the clock frequency for DMA moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetDmaFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kSystemClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDmamuxFreq - * Description : Gets the clock frequency for DMAMUX module - * This function gets the clock frequency for DMAMUX moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetDmamuxFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFreq - * Description : Gets the clock frequency for PORT module - * This function gets the clock frequency for PORT moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kLpoClock, &freq); - return freq; -} -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*! @brief CLOCK name config table for KV46*/ -const clock_name_config_t kClockNameConfigTable [] = { - {false, kSystemClock, kClockDividerOutdiv1}, /* Core clock divider */ - {false, kSystemClock, kClockDividerOutdiv1}, /* System clock divider */ - {false, kSystemClock, kClockDividerOutdiv1}, /* Not used for KV4x */ - {false, kSystemClock, kClockDividerOutdiv4}, /* Bus clock divider */ - {false, kSystemClock, kClockDividerOutdiv1}, /* Not used for KV4x*/ - {false, kSystemClock, kClockDividerOutdiv4}, /* Flash clock divider */ - {false, kSystemClock, kClockDividerOutdiv2} /* Fast peripheral clock divider */ -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSysClkFreq - * Description : Internal function to get the system clock frequency - * This function will check the clock name configuration table for specific - * chip family and find out the supported clock name for that chip family - * then it will call the mcg hal function to get the basic system clock, - * calculate the clock frequency for specified clock name. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_GetSysClkFreq(clock_names_t clockName, - uint32_t *frequency) -{ - const clock_name_config_t *table = &kClockNameConfigTable[clockName]; - - /* check if we need to use a reference clock*/ - if (table->useOtherRefClock) - { - /* get other specified ref clock*/ - if ( kClockManagerSuccess != CLOCK_SYS_GetFreq(table->otherRefClockName, - frequency) ) - { - return kClockManagerNoSuchClockName; - } - else - { - return kClockManagerSuccess; - } - } - else - { - /* get default ref clock */ - if ((table->dividerName)==kClockDividerOutdiv1) - { - *frequency =(CLOCK_HAL_GetOutClk(g_mcgBase[0])/(CLOCK_HAL_GetOutDiv1(SIM) + 1)); - } - else if ((table->dividerName)==kClockDividerOutdiv2) - { - *frequency =(CLOCK_HAL_GetOutClk(g_mcgBase[0])/(CLOCK_HAL_GetOutDiv2(SIM) + 1)); - } - else if ((table->dividerName)==kClockDividerOutdiv4) - { - *frequency =(CLOCK_HAL_GetOutClk(g_mcgBase[0])/(CLOCK_HAL_GetOutDiv4(SIM) + 1)); - } - return kClockManagerSuccess; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 2U, 5U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kFastPeripheralClock: - returnCode = CLOCK_SYS_GetSysClkFreq(clockName, frequency); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kOsc0ErClockUndiv: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; -#if FSL_FEATURE_MCG_HAS_IRC_48M - case kIrc48mClock: - *frequency = CPU_INTERNAL_IRC_48M; - break; -#endif - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the systen clock frequency. - * This function gets the systen clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFastPeripheralClockFreq - * Description : Gets the fast peripheral clock frequency. - * This function gets the fast peripheral clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFastPeripheralClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq() - >> OSC_HAL_GetExternalRefClkDiv(g_oscBase[0]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq - * Description : Gets OSC0ERCLKUDIV. - * This function gets the OSC0 external reference undivided frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx prescaler/glitch filter clock frequency. - * This function gets the LPTMRx prescaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClkUndiv: /* OSCERCLK_UNDIV clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEwmFreq - * Description : Gets the clock frequency for Ewm module - * This function gets the clock frequency for Ewm moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kLpoClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtfFreq - * Description : Gets the clock frequency for FTF module. (Flash Memory) - * This function gets the clock frequency for FTF moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFlashClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCrcFreq - * Description : Gets the clock frequency for CRC module - * This function gets the clock frequency for CRC moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kSystemClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcFreq - * Description : Gets the clock frequency for ADC module - * This function gets the clock frequency for ADC moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetAdcFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kMcgIrClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCmpFreq - * Description : Gets the clock frequency for CMP module - * This function gets the clock frequency for CMP moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPdbFreq - * Description : Gets the clock frequency for PDB module - * This function gets the clock frequency for PDB moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPwmFreq - * Description : Gets the clock frequency for eFlexPWM module - * This function gets the clock frequency for eFlexPWM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPwmFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPitFreq - * Description : Gets the clock frequency for Pit module. - * This function gets the clock frequency for Pit moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiFreq - * Description : Gets the clock frequency for SPI module. - * This function gets the clock frequency for SPI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cFreq - * Description : Gets the clock frequency for I2C module. - * This function gets the clock frequency for I2C moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetGpioFreq - * Description : Gets the clock frequency for GPIO module. - * This function gets the clock frequency for GPIO moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kSystemClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEncFreq - * Description : Gets the clock frequency for ENC module. - * This function gets the clock frequency for ENC moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEncFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetXbarFreq - * Description : Gets the clock frequency for XBAR module. - * This function gets the clock frequency for XBAR moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetXbarFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAoiFreq - * Description : Gets the clock frequency for AOI module. - * This function gets the clock frequency for AOI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetAoiFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanFreq - * Description : Gets FLEXCAN clock frequency. - * This function gets the FLEXCAN clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint8_t instance, clock_flexcan_src_t flexcanSrc) -{ - uint32_t freq = 0; - if (kClockFlexcanSrcOsc0erClk == flexcanSrc) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } - else - { - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; - } -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKV44F15/fsl_clock_MKV44F15.h b/KSDK_1.2.0/platform/system/src/clock/MKV44F15/fsl_clock_MKV44F15.h deleted file mode 100644 index c2b1691..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKV44F15/fsl_clock_MKV44F15.h +++ /dev/null @@ -1,1267 +0,0 @@ -/* - * Copyright (c) 2014 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KV44F15_H__) -#define __FSL_CLOCK_KV44F15_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -#define FTM_EXT_CLK_COUNT 2 /* FTM external clock source count. */ - -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK */ - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -} sim_config_t; - -/*! @brief Clock name configuration table structure*/ -typedef struct ClockNameConfig { - bool useOtherRefClock; /*!< if it uses the other ref clock*/ - clock_names_t otherRefClockName; /*!< other ref clock name*/ - clock_divider_names_t dividerName; /*!< clock divider name*/ -} clock_name_config_t; - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the fast peripheral clock frequency. - * - * This function gets the fast peripheral clock frequency. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetFastPeripheralClockFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selecton of ERCLK32K. - * - * This function sets the clock selecton of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selecton of ERCLK32K. - * - * This function gets the clock selecton of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets the OSC0ERCLK_UNDIV frequency. - * - * This function gets the undivided OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void); - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for DMA module. - * - * This function gets the clock frequence for DMA moudle. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetDmaFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for DMAMUX module. - * - * This function gets the clock frequence for DMAMUX moudle. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetDmamuxFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequence for EWM moudle. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequence for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequence for CRC module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for ADC module. - * - * This function gets the clock frequence for ADC module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetAdcFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequence for CMP module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance); - -/*! - * @brief Gets the frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequence for PDB module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for eFlexPWM module. - * - * This function gets the clock frequence for eFlexPWM module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetPwmFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFastPeripheralClockFreq(); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequence for PIT module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequence for SPI module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequence for I2C module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequence for UART module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequence for GPIO module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for ENC module - * - * This function gets the clock frequence for ENC module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetEncFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for XBAR module - * - * This function gets the clock frequence for XBAR module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetXbarFreq(uint32_t instance); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets the clock frequency for AOI module - * - * This function gets the clock frequence for AOI module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetAoiFreq(uint32_t instance); - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableDmaClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableDmaClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetDmaGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableDmamuxClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableDmamuxClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetDmamuxGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableEwmClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableEwmClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetEwmGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableFtfClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableFtfClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetFtfGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableCrcClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableCrcClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetCrcGateCmd(g_simBase[0], instance); -} - - - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - SIM_HAL_EnableAdcClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - SIM_HAL_DisableAdcClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetAdcGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableCmpClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableCmpClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetCmpGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - SIM_HAL_EnableDacClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - SIM_HAL_DisableDacClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - return SIM_HAL_GetDacGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnablePdbClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisablePdbClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetPdbGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - SIM_HAL_EnableFtmClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - SIM_HAL_DisableFtmClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetFtmGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnablePitClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisablePitClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetPitGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableLptmrClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableLptmrClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetLptmrGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexcanClock(uint32_t instance) -{ - SIM_HAL_EnableFlexcanClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexcanClock(uint32_t instance) -{ - SIM_HAL_DisableFlexcanClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance) -{ - return SIM_HAL_GetFlexcanGateCmd(g_simBase[0], instance); -} - - /*! - * @brief Gets FLEXCAN clock frequency. - * - * This function gets the FLEXCAN clock frequency. - * - * @param instance module device instance - * @param flexcanSrc clock source - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint8_t instance, clock_flexcan_src_t flexcanSrc); - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - SIM_HAL_EnableSpiClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - SIM_HAL_DisableSpiClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetSpiGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - SIM_HAL_EnableI2cClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - SIM_HAL_DisableI2cClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - return SIM_HAL_GetI2cGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - SIM_HAL_EnableUartClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - SIM_HAL_DisableUartClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - return SIM_HAL_GetUartGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for eFlexPWM module. - * - * This function enables the clock for eFlexPWM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePwmClock(uint32_t instance) -{ - SIM_HAL_EnablePwmClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for eFlexPWM module. - * - * This function disables the clock for eFlexPWM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePwmClock(uint32_t instance) -{ - SIM_HAL_DisablePwmClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for eFlexPWM module. - * - * This function will get the clock gate state for eFlexPWM moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetPwmGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for AOI module. - * - * This function enables the clock for AOI moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableAoiClock(uint32_t instance) -{ - SIM_HAL_EnableAoiClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for AOI module. - * - * This function disables the clock for AOI moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableAoiClock(uint32_t instance) -{ - SIM_HAL_DisableAoiClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for AOI module. - * - * This function will get the clock gate state for AOI moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetAoiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetAoiGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for XBAR module. - * - * This function enables the clock for XBAR moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableXbarClock(uint32_t instance) -{ - SIM_HAL_EnableXbarClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for XBAR module. - * - * This function disables the clock for XBAR moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableXbarClock(uint32_t instance) -{ - SIM_HAL_DisableXbarClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for XBAR module. - * - * This function will get the clock gate state for XBAR moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetXbarGateCmd(uint32_t instance) -{ - return SIM_HAL_GetXbarGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for ENC module. - * - * This function enables the clock for ENC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEncClock(uint32_t instance) -{ - SIM_HAL_EnableEncClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for ENC module. - * - * This function disables the clock for ENC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEncClock(uint32_t instance) -{ - SIM_HAL_DisableEncClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for ENC module. - * - * This function will get the clock gate state for ENC moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEncGateCmd(uint32_t instance) -{ - return SIM_HAL_GetEncGateCmd(g_simBase[0], instance); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KV44F15_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKV45F15/fsl_clock_MKV45F15.c b/KSDK_1.2.0/platform/system/src/clock/MKV45F15/fsl_clock_MKV45F15.c deleted file mode 100755 index 9d76fd3..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKV45F15/fsl_clock_MKV45F15.c +++ /dev/null @@ -1,765 +0,0 @@ -/* - * Copyright (c) 2014 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_osc_hal.h" -#include "fsl_clock_manager.h" -#include "fsl_mcg_hal_modes.h" -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/* Table of base addresses for instances. */ -extern SIM_Type * const g_simBase[]; -extern MCG_Type * const g_mcgBase[]; - -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - -/******************************************************************************* - * Code - ******************************************************************************/ -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDmaFreq - * Description : Gets the clock frequency for DMA module - * This function gets the clock frequency for DMA moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetDmaFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kSystemClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDmamuxFreq - * Description : Gets the clock frequency for DMAMUX module - * This function gets the clock frequency for DMAMUX moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetDmamuxFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFreq - * Description : Gets the clock frequency for PORT module - * This function gets the clock frequency for PORT moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kLpoClock, &freq); - return freq; -} -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*! @brief CLOCK name config table for KV46*/ -const clock_name_config_t kClockNameConfigTable [] = { - {false, kSystemClock, kClockDividerOutdiv1}, /* Core clock divider */ - {false, kSystemClock, kClockDividerOutdiv1}, /* System clock divider */ - {false, kSystemClock, kClockDividerOutdiv1}, /* Not used for KV4x */ - {false, kSystemClock, kClockDividerOutdiv4}, /* Bus clock divider */ - {false, kSystemClock, kClockDividerOutdiv1}, /* Not used for KV4x*/ - {false, kSystemClock, kClockDividerOutdiv4}, /* Flash clock divider */ - {false, kSystemClock, kClockDividerOutdiv2} /* Fast peripheral clock divider */ -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSysClkFreq - * Description : Internal function to get the system clock frequency - * This function will check the clock name configuration table for specific - * chip family and find out the supported clock name for that chip family - * then it will call the mcg hal function to get the basic system clock, - * calculate the clock frequency for specified clock name. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_GetSysClkFreq(clock_names_t clockName, - uint32_t *frequency) -{ - const clock_name_config_t *table = &kClockNameConfigTable[clockName]; - - /* check if we need to use a reference clock*/ - if (table->useOtherRefClock) - { - /* get other specified ref clock*/ - if ( kClockManagerSuccess != CLOCK_SYS_GetFreq(table->otherRefClockName, - frequency) ) - { - return kClockManagerNoSuchClockName; - } - else - { - return kClockManagerSuccess; - } - } - else - { - /* get default ref clock */ - if ((table->dividerName)==kClockDividerOutdiv1) - { - *frequency =(CLOCK_HAL_GetOutClk(g_mcgBase[0])/(CLOCK_HAL_GetOutDiv1(SIM) + 1)); - } - else if ((table->dividerName)==kClockDividerOutdiv2) - { - *frequency =(CLOCK_HAL_GetOutClk(g_mcgBase[0])/(CLOCK_HAL_GetOutDiv2(SIM) + 1)); - } - else if ((table->dividerName)==kClockDividerOutdiv4) - { - *frequency =(CLOCK_HAL_GetOutClk(g_mcgBase[0])/(CLOCK_HAL_GetOutDiv4(SIM) + 1)); - } - return kClockManagerSuccess; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 2U, 5U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kFastPeripheralClock: - returnCode = CLOCK_SYS_GetSysClkFreq(clockName, frequency); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kOsc0ErClockUndiv: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; -#if FSL_FEATURE_MCG_HAS_IRC_48M - case kIrc48mClock: - *frequency = CPU_INTERNAL_IRC_48M; - break; -#endif - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the systen clock frequency. - * This function gets the systen clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFastPeripheralClockFreq - * Description : Gets the fast peripheral clock frequency. - * This function gets the fast peripheral clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFastPeripheralClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq() - >> OSC_HAL_GetExternalRefClkDiv(g_oscBase[0]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq - * Description : Gets OSC0ERCLKUDIV. - * This function gets the OSC0 external reference undivided frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx prescaler/glitch filter clock frequency. - * This function gets the LPTMRx prescaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClkUndiv: /* OSCERCLK_UNDIV clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEwmFreq - * Description : Gets the clock frequency for Ewm module - * This function gets the clock frequency for Ewm moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kLpoClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtfFreq - * Description : Gets the clock frequency for FTF module. (Flash Memory) - * This function gets the clock frequency for FTF moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFlashClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCrcFreq - * Description : Gets the clock frequency for CRC module - * This function gets the clock frequency for CRC moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kSystemClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcFreq - * Description : Gets the clock frequency for ADC module - * This function gets the clock frequency for ADC moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetAdcFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kMcgIrClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCmpFreq - * Description : Gets the clock frequency for CMP module - * This function gets the clock frequency for CMP moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPdbFreq - * Description : Gets the clock frequency for PDB module - * This function gets the clock frequency for PDB moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPwmFreq - * Description : Gets the clock frequency for eFlexPWM module - * This function gets the clock frequency for eFlexPWM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPwmFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPitFreq - * Description : Gets the clock frequency for Pit module. - * This function gets the clock frequency for Pit moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiFreq - * Description : Gets the clock frequency for SPI module. - * This function gets the clock frequency for SPI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cFreq - * Description : Gets the clock frequency for I2C module. - * This function gets the clock frequency for I2C moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetGpioFreq - * Description : Gets the clock frequency for GPIO module. - * This function gets the clock frequency for GPIO moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kSystemClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEncFreq - * Description : Gets the clock frequency for ENC module. - * This function gets the clock frequency for ENC moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEncFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetXbarFreq - * Description : Gets the clock frequency for XBAR module. - * This function gets the clock frequency for XBAR moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetXbarFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAoiFreq - * Description : Gets the clock frequency for AOI module. - * This function gets the clock frequency for AOI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetAoiFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanFreq - * Description : Gets FLEXCAN clock frequency. - * This function gets the FLEXCAN clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint8_t instance, clock_flexcan_src_t flexcanSrc) -{ - uint32_t freq = 0; - if (kClockFlexcanSrcOsc0erClk == flexcanSrc) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } - else - { - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; - } -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKV45F15/fsl_clock_MKV45F15.h b/KSDK_1.2.0/platform/system/src/clock/MKV45F15/fsl_clock_MKV45F15.h deleted file mode 100644 index 6df9cf8..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKV45F15/fsl_clock_MKV45F15.h +++ /dev/null @@ -1,1267 +0,0 @@ -/* - * Copyright (c) 2014 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KV45F15_H__) -#define __FSL_CLOCK_KV45F15_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -#define FTM_EXT_CLK_COUNT 2 /* FTM external clock source count. */ - -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK */ - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -} sim_config_t; - -/*! @brief Clock name configuration table structure*/ -typedef struct ClockNameConfig { - bool useOtherRefClock; /*!< if it uses the other ref clock*/ - clock_names_t otherRefClockName; /*!< other ref clock name*/ - clock_divider_names_t dividerName; /*!< clock divider name*/ -} clock_name_config_t; - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the fast peripheral clock frequency. - * - * This function gets the fast peripheral clock frequency. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetFastPeripheralClockFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selecton of ERCLK32K. - * - * This function sets the clock selecton of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selecton of ERCLK32K. - * - * This function gets the clock selecton of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets the OSC0ERCLK_UNDIV frequency. - * - * This function gets the undivided OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void); - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for DMA module. - * - * This function gets the clock frequence for DMA moudle. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetDmaFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for DMAMUX module. - * - * This function gets the clock frequence for DMAMUX moudle. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetDmamuxFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequence for EWM moudle. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequence for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequence for CRC module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for ADC module. - * - * This function gets the clock frequence for ADC module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetAdcFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequence for CMP module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance); - -/*! - * @brief Gets the frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequence for PDB module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for eFlexPWM module. - * - * This function gets the clock frequence for eFlexPWM module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetPwmFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFastPeripheralClockFreq(); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequence for PIT module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequence for SPI module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequence for I2C module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequence for UART module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequence for GPIO module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for ENC module - * - * This function gets the clock frequence for ENC module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetEncFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for XBAR module - * - * This function gets the clock frequence for XBAR module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetXbarFreq(uint32_t instance); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets the clock frequency for AOI module - * - * This function gets the clock frequence for AOI module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetAoiFreq(uint32_t instance); - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableDmaClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableDmaClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetDmaGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableDmamuxClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableDmamuxClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetDmamuxGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableEwmClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableEwmClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetEwmGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableFtfClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableFtfClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetFtfGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableCrcClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableCrcClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetCrcGateCmd(g_simBase[0], instance); -} - - - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - SIM_HAL_EnableAdcClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - SIM_HAL_DisableAdcClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetAdcGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableCmpClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableCmpClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetCmpGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - SIM_HAL_EnableDacClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - SIM_HAL_DisableDacClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - return SIM_HAL_GetDacGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnablePdbClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisablePdbClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetPdbGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - SIM_HAL_EnableFtmClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - SIM_HAL_DisableFtmClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetFtmGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnablePitClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisablePitClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetPitGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableLptmrClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableLptmrClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetLptmrGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexcanClock(uint32_t instance) -{ - SIM_HAL_EnableFlexcanClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexcanClock(uint32_t instance) -{ - SIM_HAL_DisableFlexcanClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance) -{ - return SIM_HAL_GetFlexcanGateCmd(g_simBase[0], instance); -} - - /*! - * @brief Gets FLEXCAN clock frequency. - * - * This function gets the FLEXCAN clock frequency. - * - * @param instance module device instance - * @param flexcanSrc clock source - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint8_t instance, clock_flexcan_src_t flexcanSrc); - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - SIM_HAL_EnableSpiClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - SIM_HAL_DisableSpiClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetSpiGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - SIM_HAL_EnableI2cClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - SIM_HAL_DisableI2cClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - return SIM_HAL_GetI2cGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - SIM_HAL_EnableUartClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - SIM_HAL_DisableUartClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - return SIM_HAL_GetUartGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for eFlexPWM module. - * - * This function enables the clock for eFlexPWM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePwmClock(uint32_t instance) -{ - SIM_HAL_EnablePwmClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for eFlexPWM module. - * - * This function disables the clock for eFlexPWM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePwmClock(uint32_t instance) -{ - SIM_HAL_DisablePwmClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for eFlexPWM module. - * - * This function will get the clock gate state for eFlexPWM moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetPwmGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for AOI module. - * - * This function enables the clock for AOI moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableAoiClock(uint32_t instance) -{ - SIM_HAL_EnableAoiClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for AOI module. - * - * This function disables the clock for AOI moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableAoiClock(uint32_t instance) -{ - SIM_HAL_DisableAoiClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for AOI module. - * - * This function will get the clock gate state for AOI moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetAoiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetAoiGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for XBAR module. - * - * This function enables the clock for XBAR moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableXbarClock(uint32_t instance) -{ - SIM_HAL_EnableXbarClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for XBAR module. - * - * This function disables the clock for XBAR moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableXbarClock(uint32_t instance) -{ - SIM_HAL_DisableXbarClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for XBAR module. - * - * This function will get the clock gate state for XBAR moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetXbarGateCmd(uint32_t instance) -{ - return SIM_HAL_GetXbarGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for ENC module. - * - * This function enables the clock for ENC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEncClock(uint32_t instance) -{ - SIM_HAL_EnableEncClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for ENC module. - * - * This function disables the clock for ENC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEncClock(uint32_t instance) -{ - SIM_HAL_DisableEncClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for ENC module. - * - * This function will get the clock gate state for ENC moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEncGateCmd(uint32_t instance) -{ - return SIM_HAL_GetEncGateCmd(g_simBase[0], instance); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KV45F15_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKV46F15/fsl_clock_MKV46F15.c b/KSDK_1.2.0/platform/system/src/clock/MKV46F15/fsl_clock_MKV46F15.c deleted file mode 100755 index 9d76fd3..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKV46F15/fsl_clock_MKV46F15.c +++ /dev/null @@ -1,765 +0,0 @@ -/* - * Copyright (c) 2014 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_osc_hal.h" -#include "fsl_clock_manager.h" -#include "fsl_mcg_hal_modes.h" -/******************************************************************************* - * Definitions - ******************************************************************************/ - -/* Table of base addresses for instances. */ -extern SIM_Type * const g_simBase[]; -extern MCG_Type * const g_mcgBase[]; - -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - -/******************************************************************************* - * Code - ******************************************************************************/ -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDmaFreq - * Description : Gets the clock frequency for DMA module - * This function gets the clock frequency for DMA moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetDmaFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kSystemClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDmamuxFreq - * Description : Gets the clock frequency for DMAMUX module - * This function gets the clock frequency for DMAMUX moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetDmamuxFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFreq - * Description : Gets the clock frequency for PORT module - * This function gets the clock frequency for PORT moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kLpoClock, &freq); - return freq; -} -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*! @brief CLOCK name config table for KV46*/ -const clock_name_config_t kClockNameConfigTable [] = { - {false, kSystemClock, kClockDividerOutdiv1}, /* Core clock divider */ - {false, kSystemClock, kClockDividerOutdiv1}, /* System clock divider */ - {false, kSystemClock, kClockDividerOutdiv1}, /* Not used for KV4x */ - {false, kSystemClock, kClockDividerOutdiv4}, /* Bus clock divider */ - {false, kSystemClock, kClockDividerOutdiv1}, /* Not used for KV4x*/ - {false, kSystemClock, kClockDividerOutdiv4}, /* Flash clock divider */ - {false, kSystemClock, kClockDividerOutdiv2} /* Fast peripheral clock divider */ -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSysClkFreq - * Description : Internal function to get the system clock frequency - * This function will check the clock name configuration table for specific - * chip family and find out the supported clock name for that chip family - * then it will call the mcg hal function to get the basic system clock, - * calculate the clock frequency for specified clock name. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_GetSysClkFreq(clock_names_t clockName, - uint32_t *frequency) -{ - const clock_name_config_t *table = &kClockNameConfigTable[clockName]; - - /* check if we need to use a reference clock*/ - if (table->useOtherRefClock) - { - /* get other specified ref clock*/ - if ( kClockManagerSuccess != CLOCK_SYS_GetFreq(table->otherRefClockName, - frequency) ) - { - return kClockManagerNoSuchClockName; - } - else - { - return kClockManagerSuccess; - } - } - else - { - /* get default ref clock */ - if ((table->dividerName)==kClockDividerOutdiv1) - { - *frequency =(CLOCK_HAL_GetOutClk(g_mcgBase[0])/(CLOCK_HAL_GetOutDiv1(SIM) + 1)); - } - else if ((table->dividerName)==kClockDividerOutdiv2) - { - *frequency =(CLOCK_HAL_GetOutClk(g_mcgBase[0])/(CLOCK_HAL_GetOutDiv2(SIM) + 1)); - } - else if ((table->dividerName)==kClockDividerOutdiv4) - { - *frequency =(CLOCK_HAL_GetOutClk(g_mcgBase[0])/(CLOCK_HAL_GetOutDiv4(SIM) + 1)); - } - return kClockManagerSuccess; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 2U, 5U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kFastPeripheralClock: - returnCode = CLOCK_SYS_GetSysClkFreq(clockName, frequency); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kOsc0ErClockUndiv: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; -#if FSL_FEATURE_MCG_HAS_IRC_48M - case kIrc48mClock: - *frequency = CPU_INTERNAL_IRC_48M; - break; -#endif - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the systen clock frequency. - * This function gets the systen clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFastPeripheralClockFreq - * Description : Gets the fast peripheral clock frequency. - * This function gets the fast peripheral clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFastPeripheralClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq() - >> OSC_HAL_GetExternalRefClkDiv(g_oscBase[0]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq - * Description : Gets OSC0ERCLKUDIV. - * This function gets the OSC0 external reference undivided frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx prescaler/glitch filter clock frequency. - * This function gets the LPTMRx prescaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClkUndiv: /* OSCERCLK_UNDIV clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEwmFreq - * Description : Gets the clock frequency for Ewm module - * This function gets the clock frequency for Ewm moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kLpoClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtfFreq - * Description : Gets the clock frequency for FTF module. (Flash Memory) - * This function gets the clock frequency for FTF moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFlashClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCrcFreq - * Description : Gets the clock frequency for CRC module - * This function gets the clock frequency for CRC moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kSystemClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcFreq - * Description : Gets the clock frequency for ADC module - * This function gets the clock frequency for ADC moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetAdcFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kMcgIrClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCmpFreq - * Description : Gets the clock frequency for CMP module - * This function gets the clock frequency for CMP moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPdbFreq - * Description : Gets the clock frequency for PDB module - * This function gets the clock frequency for PDB moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPwmFreq - * Description : Gets the clock frequency for eFlexPWM module - * This function gets the clock frequency for eFlexPWM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPwmFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPitFreq - * Description : Gets the clock frequency for Pit module. - * This function gets the clock frequency for Pit moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiFreq - * Description : Gets the clock frequency for SPI module. - * This function gets the clock frequency for SPI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cFreq - * Description : Gets the clock frequency for I2C module. - * This function gets the clock frequency for I2C moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetGpioFreq - * Description : Gets the clock frequency for GPIO module. - * This function gets the clock frequency for GPIO moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kSystemClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetEncFreq - * Description : Gets the clock frequency for ENC module. - * This function gets the clock frequency for ENC moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetEncFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetXbarFreq - * Description : Gets the clock frequency for XBAR module. - * This function gets the clock frequency for XBAR moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetXbarFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAoiFreq - * Description : Gets the clock frequency for AOI module. - * This function gets the clock frequency for AOI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetAoiFreq(uint32_t instance) -{ - uint32_t freq = 0; - CLOCK_SYS_GetFreq(kBusClock, &freq); - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlexcanFreq - * Description : Gets FLEXCAN clock frequency. - * This function gets the FLEXCAN clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint8_t instance, clock_flexcan_src_t flexcanSrc) -{ - uint32_t freq = 0; - if (kClockFlexcanSrcOsc0erClk == flexcanSrc) - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } - else - { - CLOCK_SYS_GetFreq(kFastPeripheralClock, &freq); - return freq; - } -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKV46F15/fsl_clock_MKV46F15.h b/KSDK_1.2.0/platform/system/src/clock/MKV46F15/fsl_clock_MKV46F15.h deleted file mode 100644 index 1c17dcc..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKV46F15/fsl_clock_MKV46F15.h +++ /dev/null @@ -1,1267 +0,0 @@ -/* - * Copyright (c) 2014 - 2015, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KV46F15_H__) -#define __FSL_CLOCK_KV46F15_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -#define FTM_EXT_CLK_COUNT 2 /* FTM external clock source count. */ - -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK */ - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -} sim_config_t; - -/*! @brief Clock name configuration table structure*/ -typedef struct ClockNameConfig { - bool useOtherRefClock; /*!< if it uses the other ref clock*/ - clock_names_t otherRefClockName; /*!< other ref clock name*/ - clock_divider_names_t dividerName; /*!< clock divider name*/ -} clock_name_config_t; - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the fast peripheral clock frequency. - * - * This function gets the fast peripheral clock frequency. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetFastPeripheralClockFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selecton of ERCLK32K. - * - * This function sets the clock selecton of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selecton of ERCLK32K. - * - * This function gets the clock selecton of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets the OSC0ERCLK_UNDIV frequency. - * - * This function gets the undivided OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq(void); - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for DMA module. - * - * This function gets the clock frequence for DMA moudle. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetDmaFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for DMAMUX module. - * - * This function gets the clock frequence for DMAMUX moudle. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetDmamuxFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequence for EWM moudle. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequence for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequence for CRC module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for ADC module. - * - * This function gets the clock frequence for ADC module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetAdcFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequence for CMP module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance); - -/*! - * @brief Gets the frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequence for PDB module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for eFlexPWM module. - * - * This function gets the clock frequence for eFlexPWM module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetPwmFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFastPeripheralClockFreq(); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequence for PIT module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequence for SPI module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequence for I2C module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequence for UART module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequence for GPIO module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for ENC module - * - * This function gets the clock frequence for ENC module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetEncFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for XBAR module - * - * This function gets the clock frequence for XBAR module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetXbarFreq(uint32_t instance); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets the clock frequency for AOI module - * - * This function gets the clock frequence for AOI module. - * @param instance module device instance - * @return freq clock frequence for this module - */ -uint32_t CLOCK_SYS_GetAoiFreq(uint32_t instance); - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableDmaClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableDmaClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetDmaGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableDmamuxClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableDmamuxClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetDmamuxGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableEwmClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableEwmClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetEwmGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableFtfClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableFtfClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetFtfGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableCrcClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableCrcClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetCrcGateCmd(g_simBase[0], instance); -} - - - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - SIM_HAL_EnableAdcClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - SIM_HAL_DisableAdcClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetAdcGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableCmpClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableCmpClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetCmpGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - SIM_HAL_EnableDacClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - SIM_HAL_DisableDacClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - return SIM_HAL_GetDacGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnablePdbClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisablePdbClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetPdbGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - SIM_HAL_EnableFtmClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - SIM_HAL_DisableFtmClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetFtmGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnablePitClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisablePitClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetPitGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableLptmrClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableLptmrClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetLptmrGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for FLEXCAN module. - * - * This function enables the clock for FLEXCAN moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFlexcanClock(uint32_t instance) -{ - SIM_HAL_EnableFlexcanClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for FLEXCAN module. - * - * This function disables the clock for FLEXCAN moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFlexcanClock(uint32_t instance) -{ - SIM_HAL_DisableFlexcanClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for FLEXCAN module. - * - * This function will get the clock gate state for FLEXCAN moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFlexcanGateCmd(uint32_t instance) -{ - return SIM_HAL_GetFlexcanGateCmd(g_simBase[0], instance); -} - - /*! - * @brief Gets FLEXCAN clock frequency. - * - * This function gets the FLEXCAN clock frequency. - * - * @param instance module device instance - * @param flexcanSrc clock source - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetFlexcanFreq(uint8_t instance, clock_flexcan_src_t flexcanSrc); - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - SIM_HAL_EnableSpiClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - SIM_HAL_DisableSpiClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetSpiGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - SIM_HAL_EnableI2cClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - SIM_HAL_DisableI2cClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - return SIM_HAL_GetI2cGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - SIM_HAL_EnableUartClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - SIM_HAL_DisableUartClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - return SIM_HAL_GetUartGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for eFlexPWM module. - * - * This function enables the clock for eFlexPWM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePwmClock(uint32_t instance) -{ - SIM_HAL_EnablePwmClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for eFlexPWM module. - * - * This function disables the clock for eFlexPWM moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePwmClock(uint32_t instance) -{ - SIM_HAL_DisablePwmClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for eFlexPWM module. - * - * This function will get the clock gate state for eFlexPWM moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetPwmGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for AOI module. - * - * This function enables the clock for AOI moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableAoiClock(uint32_t instance) -{ - SIM_HAL_EnableAoiClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for AOI module. - * - * This function disables the clock for AOI moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableAoiClock(uint32_t instance) -{ - SIM_HAL_DisableAoiClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for AOI module. - * - * This function will get the clock gate state for AOI moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetAoiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetAoiGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for XBAR module. - * - * This function enables the clock for XBAR moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableXbarClock(uint32_t instance) -{ - SIM_HAL_EnableXbarClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for XBAR module. - * - * This function disables the clock for XBAR moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableXbarClock(uint32_t instance) -{ - SIM_HAL_DisableXbarClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for XBAR module. - * - * This function will get the clock gate state for XBAR moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetXbarGateCmd(uint32_t instance) -{ - return SIM_HAL_GetXbarGateCmd(g_simBase[0], instance); -} - -/*! - * @brief Enable the clock for ENC module. - * - * This function enables the clock for ENC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEncClock(uint32_t instance) -{ - SIM_HAL_EnableEncClock(g_simBase[0], instance); -} - -/*! - * @brief Disable the clock for ENC module. - * - * This function disables the clock for ENC moudle. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEncClock(uint32_t instance) -{ - SIM_HAL_DisableEncClock(g_simBase[0], instance); -} - -/*! - * @brief Get the the clock gate state for ENC module. - * - * This function will get the clock gate state for ENC moudle. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEncGateCmd(uint32_t instance) -{ - return SIM_HAL_GetEncGateCmd(g_simBase[0], instance); -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KV46F15_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKW01Z4/fsl_clock_MKW01Z4.c b/KSDK_1.2.0/platform/system/src/clock/MKW01Z4/fsl_clock_MKW01Z4.c deleted file mode 100755 index 7ea8af3..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKW01Z4/fsl_clock_MKW01Z4.c +++ /dev/null @@ -1,1012 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_sim_hal.h" -#include "fsl_mcg_hal.h" -#include "fsl_clock_manager.h" - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; /* TPM_CLK */ -#if FSL_FEATURE_SOC_USB_COUNT -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -#endif - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - 0U, - 0U, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - - CLOCK_HAL_SetOutDiv(SIM, 2U, 0U, 0U, 4U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - - /*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the systen clock frequency. - * This function gets the systen clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_SYS_GetSystemClockFreq() / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - freq >>= 1U; /* divided by 2 for special divider */ - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return CLOCK_SYS_GetExternalRefClock32kFreq() >> 15U; - } - else - { - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCopFreq - * Description : Gets COP clock frequency. - * This function gets the COP clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCopFreq(uint32_t instance, clock_cop_src_t copSrc) -{ - if (kClockCopSrcLpoClk == copSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcFreq - * Description : Gets rtc clock frequency. - * This function gets rtc clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmfFreq - * Description : Gets the clock frequency for TPM module. - * This function gets the clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance) -{ - uint32_t freq; - clock_tpm_src_t src; - - src = CLOCK_HAL_GetTpmSrc(SIM, instance); - - switch(src) - { - case kClockTpmSrcPllFllSel: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockTpmSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockTpmSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmExternalFreq - * Description : Gets the external clock frequency for TPM module. - * This function gets the external clock frequency for TPM moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance) -{ - sim_tpm_clk_sel_t src = CLOCK_SYS_GetTpmExternalSrc(instance); - - if (kSimTpmClkSel0 == src) - { - return g_tpmClkFreq[0]; - } - else - { - return g_tpmClkFreq[1]; - } -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - return freq; - } -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpifFreq - * Description : Gets the clock frequency for SPI module. - * This function gets the clock frequency for SPI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetBusClockFreq(); /* BUS CLOCK */ - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); /* SYSTEM CLOCK*/ - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cfFreq - * Description : Gets the clock frequency for I2C module. - * This function gets the clock frequency for I2C moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetBusClockFreq(); /* BUS CLOCK */ - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); /* SYSTEM CLOCK*/ - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLpsciFreq - * Description : Gets the clock frequency for LPSCI module. - * This function gets the clock frequency for LPSCI moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLpsciFreq(uint32_t instance) -{ - uint32_t freq; - clock_lpsci_src_t src; - - src = CLOCK_HAL_GetLpsciSrc(SIM, instance); - - switch(src) - { - case kClockLpsciSrcPllFllSel: /* FLL/PLL */ - freq = CLOCK_SYS_GetPllFllClockFreq(); - break; - case kClockLpsciSrcOsc0erClk: /* OSCERCLK */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockLpsciSrcMcgIrClk: /* MCGIRCLK. */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART moudle. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq = 0; - - switch (instance) - { - case 0: - case 1: - case 2: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Lpsci instance table. */ -static const sim_clock_gate_name_t lpsciGateTable[] = -{ - kSimClockGateLpsci0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableLpsciClock - * Description : Enable the clock for LPSCI module - * This function disable the clock for LPSCI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableLpsciClock(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - SIM_HAL_DisableClock(SIM, lpsciGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetLpsciGateCmd - * Description : Get the the clock gate state for LPSCI module - * This function will get the clock gate state for LPSCI moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetLpsciGateCmd(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, lpsciGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableLpsciClock - * Description : Enable the clock for LPSCI module - * This function enables the clock for LPSCI moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableLpsciClock(uint32_t instance) -{ - assert(instance < sizeof(lpsciGateTable)/sizeof(lpsciGateTable[0])); - - SIM_HAL_EnableClock(SIM, lpsciGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - (sim_clock_gate_name_t)(-1), - kSimClockGateUart1, - kSimClockGateUart2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t tpmGateTable[] = -{ - kSimClockGateTpm0, - kSimClockGateTpm1, - kSimClockGateTpm2 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableTpmClock - * Description : Enable the clock for TPM module - * This function enables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_EnableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_EnableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableTpmClock - * Description : Disable the clock for TPM module - * This function disables the clock for TPM moudle - * - *END**************************************************************************/ -void CLOCK_SYS_DisableTpmClock(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - SIM_HAL_DisableClock(SIM, tpmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTpmGateCmd - * Description : Get the the clock gate state for TPM module - * This function will get the clock gate state for TPM moudle. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(tpmGateTable)/sizeof(tpmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, tpmGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKW01Z4/fsl_clock_MKW01Z4.h b/KSDK_1.2.0/platform/system/src/clock/MKW01Z4/fsl_clock_MKW01Z4.h deleted file mode 100644 index 5b8be7e..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKW01Z4/fsl_clock_MKW01Z4.h +++ /dev/null @@ -1,1236 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KW01Z4_H__) -#define __FSL_CLOCK_KW01Z4_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kl46z4 */ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief TPM external clock source count. */ -#define TPM_EXT_CLK_COUNT 2 -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 - -/*! @brief TPM external clock frequency(TPM_CLK). */ -extern uint32_t g_tpmClkFreq[TPM_EXT_CLK_COUNT]; -#if FSL_FEATURE_SOC_USB_COUNT -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -#endif - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} osc_user_config_kw01z4_t; -#else -} sim_config_t; -#endif - -/*! @}*/ - -/*! @addtogroup clock_manager*/ -/*! @{*/ - -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the COP clock frequency. - * - * This function gets the COP clock frequency. - * - * @param instance module device instance - * @param copSrc COP clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetCopFreq(uint32_t instance, clock_cop_src_t copSrc); - - /*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - -/*! - * @brief Gets TPM clock frequency. - * - * This function gets the TPM clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTpmFreq(uint32_t instance); - -/*! - * @brief Set the TPM clock source selection. - * - * This function sets the TPM clock source selection. - * - * @param instance IP instance. - * @param tpmSrc The value to set. - */ -static inline void CLOCK_SYS_SetTpmSrc(uint32_t instance, clock_tpm_src_t tpmSrc) -{ - CLOCK_HAL_SetTpmSrc(SIM, instance, tpmSrc); -} - -/*! - * @brief Get the TPM clock source selection. - * - * This function gets the TPM clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_tpm_src_t CLOCK_SYS_GetTpmSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTpmSrc(SIM, instance); -} - -/*! - * @brief Get the TPM external clock source frequency. - * - * This function gets the TPM external clock source frequency. - * - * @param instance IP instance. - * @return TPM external clock frequency. - */ -uint32_t CLOCK_SYS_GetTpmExternalFreq(uint32_t instance); - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @param src TPM external clock source. - */ -static inline void CLOCK_SYS_SetTpmExternalSrc(uint32_t instance, sim_tpm_clk_sel_t src) -{ - SIM_HAL_SetTpmExternalClkPinSelMode(SIM, instance, src); -} - -/*! - * @brief Set the TPM external clock source selection. - * - * This function sets the TPM external clock source selection. - * - * @param instance IP instance. - * @return setting Current TPM external clock source. - */ -static inline sim_tpm_clk_sel_t CLOCK_SYS_GetTpmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetTpmExternalClkPinSelMode(SIM, instance); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set the selection of the clock source for the USB FS 48 MHz clock. - * - * This function sets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @param usbfsSrc The value to set. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Get the selection of the clock source for the USB FS 48 MHz clock. - * - * This function gets the selection of the clock source for the USB FS 48 MHz clock. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance); - - /*! - * @brief Gets the clock frequency for LPSCI module. - * - * This function gets the clock frequency for LPSCI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetLpsciFreq(uint32_t instance); - -/*! - * @brief Set the LPSCI clock source selection. - * - * This function sets the LPSCI clock source selection. - * - * @param instance IP instance. - * @param lpsciSrc The value to set. - */ -static inline void CLOCK_SYS_SetLpsciSrc(uint32_t instance, clock_lpsci_src_t lpsciSrc) -{ - CLOCK_HAL_SetLpsciSrc(SIM, instance, lpsciSrc); -} - -/*! - * @brief Get the LPSCI clock source selection. - * - * This function gets the LPSCI clock source selection. - * - * @param instance IP instance. - * @return Current selection. - */ -static inline clock_lpsci_src_t CLOCK_SYS_GetLpsciSrc(uint32_t instance) -{ - return CLOCK_HAL_GetLpsciSrc(SIM, instance); -} - -/*! - * @brief Get the UART clock frequency. - * - * This function gets the UART clock frequency. - * - * @param instance IP instance. - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_LCD_COUNT -/*! - * @brief Enable the clock for SLCD module. - * - * This function enables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSlcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Disable the clock for SLCD module. - * - * This function disables the clock for SLCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSlcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Get the the clock gate state for SLCD module. - * - * This function will get the clock gate state for SLCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSlcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSlcd0); -} - -/*! - * @brief Gets the frequency for SLCD default clock. - * - * This function gets the frequency for SLCD default clock. - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdDefaultFreq(uint32_t instance) -{ - return CLOCK_SYS_GetExternalRefClock32kFreq(); -} - -/*! - * @brief Gets the frequency for SLCD alternate clock. - * - * This function gets the frequency for SLCD alternate clock (ALTSOURCE = 0). - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAltFreq(uint32_t instance) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the frequency for SLCD alternate 2 clock. - * - * This function gets the frequency for SLCD alternate 2 clock (ALTSOURCE = 1). - * - * @param instance module device instance. - * @return freq clock frequency for this module. - */ -static inline uint32_t CLOCK_SYS_GetSlcdAlt2Freq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} -#endif// FSL_FEATURE_SOC_LCD_COUNT - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp0); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for TPM module. - * - * This function enables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableTpmClock(uint32_t instance); - -/*! - * @brief Disable the clock for TPM module. - * - * This function disables the clock for TPM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableTpmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for TPM module. - * - * This function will get the clock gate state for TPM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetTpmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for TSI module. - * - * This function enables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableTsiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Disable the clock for TSI module. - * - * This function disables the clock for TSI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableTsiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Get the the clock gate state for TSI module. - * - * This function will get the clock gate state for TSI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetTsiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateTsi0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for LPSCI module. - * - * This function enables the clock for LPSCI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableLpsciClock(uint32_t instance); - -/*! - * @brief Disable the clock for LPSCI module. - * - * This function disables the clock for LPSCI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableLpsciClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for LPSCI module. - * - * This function will get the clock gate state for LPSCI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetLpsciGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -#if FSL_FEATURE_SOC_USB_COUNT -/*! - * @brief Set the USB external clock frequency(USB_CLKIN). - * - * This function sets the USB external clock frequency (USB_CLKIN). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetUsbExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < USB_EXT_CLK_COUNT); - - g_usbClkInFreq[srcInstance] = freq; -} -#endif// FSL_FEATURE_SOC_USB_COUNT - -/*! - * @brief Set the TPM external clock frequency(TPM_CLKx). - * - * This function sets the TPM external clock frequency (TPM_CLKx). - * - * @param srcInstance External source instance. - * @param freq Frequcney value. - */ -static inline void CLOCK_SYS_SetTpmExternalFreq(uint32_t srcInstance, uint32_t freq) -{ - assert(srcInstance < TPM_EXT_CLK_COUNT); - - g_tpmClkFreq[srcInstance] = freq; -} - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KW01Z4_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKW21D5/fsl_clock_MKW21D5.c b/KSDK_1.2.0/platform/system/src/clock/MKW21D5/fsl_clock_MKW21D5.c deleted file mode 100755 index 4e8f36b..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKW21D5/fsl_clock_MKW21D5.c +++ /dev/null @@ -1,861 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_osc_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 1U, 4U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG) / 2U; - } - else - { - return CLOCK_SYS_GetCoreClockFreq() / 2U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - case 3: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - case 4: - case 5: - - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, - kSimClockGateUart3 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKW21D5/fsl_clock_MKW21D5.h b/KSDK_1.2.0/platform/system/src/clock/MKW21D5/fsl_clock_MKW21D5.h deleted file mode 100644 index 3866c96..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKW21D5/fsl_clock_MKW21D5.h +++ /dev/null @@ -1,1436 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KW21DA5_H__) -#define __FSL_CLOCK_KW21DA5_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kw21d5*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kw21d5_t; -#else -} sim_config_t; -#endif - -/*! @brief Default clock configuration number. */ -#define CLOCK_CONFIG_NUM 2 - -/*! @brief Clock configuration index for VLPR mode. */ -#define CLOCK_CONFIG_INDEX_FOR_VLPR 0 - -/*! @brief Clock configuration index for RUN mode. */ -#define CLOCK_CONFIG_INDEX_FOR_RUN 1 - -/*! @} */ -/*! @addtogroup clock_manager*/ -/*! @{*/ -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} - - - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for USB DCD module - * - * This function gets the clock frequency for USB DCD module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetUsbdcdFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for CMT module. - * - * This function enables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmtClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Disable the clock for CMT module. - * - * This function disables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmtClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Get the the clock gate state for CMT module. - * - * This function will get the clock gate state for CMT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmtGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for USBDCD module. - * - * This function enables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Disable the clock for USBDCD module. - * - * This function disables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Get the the clock gate state for USBDCD module. - * - * This function will get the clock gate state for USBDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KW21DA5_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKW22D5/fsl_clock_MKW22D5.c b/KSDK_1.2.0/platform/system/src/clock/MKW22D5/fsl_clock_MKW22D5.c deleted file mode 100755 index 8ab1d63..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKW22D5/fsl_clock_MKW22D5.c +++ /dev/null @@ -1,891 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_osc_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 1U, 4U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG) / 2U; - } - else - { - return CLOCK_SYS_GetCoreClockFreq() / 2U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} - - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - case 3: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - case 4: - case 5: - - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, - kSimClockGateUart3 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKW22D5/fsl_clock_MKW22D5.h b/KSDK_1.2.0/platform/system/src/clock/MKW22D5/fsl_clock_MKW22D5.h deleted file mode 100644 index bf386fd..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKW22D5/fsl_clock_MKW22D5.h +++ /dev/null @@ -1,1460 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KW22DA5_H__) -#define __FSL_CLOCK_KW22DA5_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kw22d5*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kw22d5_t; -#else -} sim_config_t; -#endif - -/*! @brief Default clock configuration number. */ -#define CLOCK_CONFIG_NUM 2 - -/*! @brief Clock configuration index for VLPR mode. */ -#define CLOCK_CONFIG_INDEX_FOR_VLPR 0 - -/*! @brief Clock configuration index for RUN mode. */ -#define CLOCK_CONFIG_INDEX_FOR_RUN 1 - -/*! @} */ -/*! @addtogroup clock_manager*/ -/*! @{*/ -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} - - - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for USB DCD module - * - * This function gets the clock frequency for USB DCD module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetUsbdcdFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for CMT module. - * - * This function enables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmtClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Disable the clock for CMT module. - * - * This function disables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmtClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Get the the clock gate state for CMT module. - * - * This function will get the clock gate state for CMT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmtGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for USBDCD module. - * - * This function enables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Disable the clock for USBDCD module. - * - * This function disables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Get the the clock gate state for USBDCD module. - * - * This function will get the clock gate state for USBDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KW22DA5_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - diff --git a/KSDK_1.2.0/platform/system/src/clock/MKW24D5/fsl_clock_MKW24D5.c b/KSDK_1.2.0/platform/system/src/clock/MKW24D5/fsl_clock_MKW24D5.c deleted file mode 100755 index 8ab1d63..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKW24D5/fsl_clock_MKW24D5.c +++ /dev/null @@ -1,891 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include "fsl_device_registers.h" -#include "fsl_mcg_hal.h" -#include "fsl_sim_hal.h" -#include "fsl_osc_hal.h" -#include "fsl_clock_manager.h" - -/* - * README: - * This file should provide these APIs: - * 1. APIs to get the frequency of output clocks in Reference Manual -> - * Chapter Clock Distribution -> Figure Clocking diagram. - * 2. APIs for IP modules listed in Reference Manual -> Chapter Clock Distribution - * -> Module clocks. - */ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; /* USB_CLKIN */ -uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; /* FTM_CLK0 */ - -/******************************************************************************* - * Code - ******************************************************************************/ - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_FllStableDelay - * Description : This funtion is used to delay for FLL stable. - * According to datasheet, every time the FLL reference source or reference - * divider is changed, trim value is changed, DMX32 bit is changed, DRS bits - * are changed, or changing from FLL disabled (BLPE, BLPI) to FLL enabled - * (FEI, FEE, FBE, FBI), there should be 1ms delay for FLL stable. Please - * check datasheet for t(fll_aquire). - * - *END**************************************************************************/ -static void CLOCK_SYS_FllStableDelay(void) -{ - uint32_t coreClk = CLOCK_SYS_GetCoreClockFreq(); - - coreClk /= 3000U; - - // Delay 1 ms. - while (coreClk--) - { - __asm ("nop"); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetSimConfigration - * Description : This funtion sets the SIM registers for clock transitiom. - * - *END**************************************************************************/ -static void CLOCK_SYS_SetSimConfigration(sim_config_t const *simConfig) -{ - CLOCK_HAL_SetOutDiv(SIM, - simConfig->outdiv1, - simConfig->outdiv2, - simConfig->outdiv3, - simConfig->outdiv4); - - CLOCK_HAL_SetPllfllSel(SIM, simConfig->pllFllSel); - - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, simConfig->er32kSrc); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_SetConfiguration - * Description : This funtion sets the system to target configuration, it - * only sets the clock modules registers for clock mode change, but not send - * notifications to drivers. - * - *END**************************************************************************/ -clock_manager_error_code_t CLOCK_SYS_SetConfiguration(clock_manager_user_config_t const* config) -{ - assert(NULL != config); - - /* Set outdiv for safe output clock frequency. */ - CLOCK_HAL_SetOutDiv(SIM, 0U, 1U, 1U, 4U); - - /* Set MCG mode. */ - CLOCK_SYS_SetMcgMode(&config->mcgConfig, CLOCK_SYS_FllStableDelay); - - /* Set SIM setting. */ - CLOCK_SYS_SetSimConfigration(&config->simConfig); - - /* Set OSCERCLK setting. */ - CLOCK_SYS_SetOscerConfigration(0, &config->oscerConfig); - SystemCoreClock = CLOCK_SYS_GetCoreClockFreq(); - - return kClockManagerSuccess; -} - -clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName, - uint32_t *frequency) -{ - clock_manager_error_code_t returnCode = kClockManagerSuccess; - - switch (clockName) - { - case kCoreClock: - case kSystemClock: - *frequency = CLOCK_SYS_GetCoreClockFreq(); - break; - case kPlatformClock: - *frequency = CLOCK_SYS_GetSystemClockFreq(); - break; - case kBusClock: - *frequency = CLOCK_SYS_GetBusClockFreq(); - break; - case kFlashClock: - *frequency = CLOCK_SYS_GetFlashClockFreq(); - break; - case kOsc32kClock: - *frequency = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kOsc0ErClock: - *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kRtcoutClock: - *frequency = CLOCK_SYS_GetRtcOutFreq(); - break; - case kMcgFfClock: - *frequency = CLOCK_SYS_GetFixedFreqClockFreq(); - break; - case kMcgFllClock: - *frequency = CLOCK_HAL_GetFllClk(MCG); - break; - case kMcgPll0Clock: - *frequency = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kMcgOutClock: - *frequency = CLOCK_HAL_GetOutClk(MCG); - break; - case kMcgIrClock: - *frequency = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kLpoClock: - *frequency = CLOCK_SYS_GetLpoClockFreq(); - break; - case kSystickClock: - *frequency = CLOCK_SYS_GetSystickFreq(); - break; - default: - *frequency = 0U; - returnCode = kClockManagerNoSuchClockName; - break; - } - - return returnCode; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetCoreClockFreq - * Description : Gets the core clock frequency. - * This function gets the core clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetCoreClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSystemClockFreq - * Description : Gets the system clock frequency. - * This function gets the system clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSystemClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv1(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetBusClockFreq - * Description : Gets the bus clock frequency. - * This function gets the bus clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetBusClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv2(SIM) + 1); -} - - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFlashClockFreq - * Description : Gets the flash clock frequency. - * This function gets the flash clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFlashClockFreq(void) -{ - return CLOCK_HAL_GetOutClk(MCG) / (CLOCK_HAL_GetOutDiv4(SIM) + 1); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPllFllClockFreq - * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void) -{ - uint32_t freq; - clock_pllfll_sel_t src; - - src = CLOCK_HAL_GetPllfllSel(SIM); - - switch (src) - { - case kClockPllFllSelFll: - freq = CLOCK_HAL_GetFllClk(MCG); - break; - case kClockPllFllSelPll: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - default: - freq = 0U; - break; - } - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetRtcOutFreq - * Description : Gets the RTC_CLKOUT frequency. - * This function gets RTC_CLKOUT clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetRtcOutFreq(void) -{ - if (kClockRtcoutSrc1Hz == CLOCK_SYS_GetRtcOutSrc()) - { - return g_xtalRtcClkFreq >> 15U; - } - else - { - return g_xtalRtcClkFreq; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetExternalRefClockFreq - * Description : Gets the ERCLK32K clock frequency. - * This function gets the external reference (ERCLK32K) clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void) -{ - clock_er32k_src_t src; - uint32_t freq; - - src = CLOCK_HAL_GetExternalRefClock32kSrc(SIM); - switch (src) - { - case kClockEr32kSrcOsc0: /* OSC 32k clock */ - freq = (32768U == g_xtal0ClkFreq) ? 32768U : 0U; - break; - case kClockEr32kSrcRtc: /* RTC 32k clock */ - freq = g_xtalRtcClkFreq; - break; - case kClockEr32kSrcLpo: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetOsc0ExternalRefClockFreq - * Description : Gets OSC0ERCLK. - * This function gets the OSC0 external reference frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void) -{ - if (OSC_HAL_GetExternalRefClkCmd(g_oscBase[0])) - { - return g_xtal0ClkFreq; - } - else - { - return 0U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetWdogFreq - * Description : Gets watch dog clock frequency. - * This function gets the watch dog clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc) -{ - if (kClockWdogSrcLpoClk == wdogSrc) - { - return CLOCK_SYS_GetLpoClockFreq(); - } - else - { - return CLOCK_SYS_GetBusClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetTraceFreq - * Description : Gets debug trace clock frequency. - * This function gets the debug trace clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance) -{ - clock_trace_src_t src = CLOCK_HAL_GetTraceClkSrc(SIM); - - if (kClockTraceSrcMcgoutClk == src) - { - return CLOCK_HAL_GetOutClk(MCG) / 2U; - } - else - { - return CLOCK_SYS_GetCoreClockFreq() / 2U; - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortFilterFreq - * Description : Gets PORTx digital input filter clock frequency. - * This function gets the PORTx digital input filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src) -{ - if (kClockPortFilterSrcBusClk == src) - { - return CLOCK_SYS_GetBusClockFreq(); - } - else - { - return CLOCK_SYS_GetLpoClockFreq(); - } -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetLptmrFreq - * Description : Gets LPTMRx pre-scaler/glitch filter clock frequency. - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc) -{ - uint32_t freq; - - switch (lptmrSrc) - { - case kClockLptmrSrcMcgIrClk: /* MCG out clock */ - freq = CLOCK_HAL_GetInternalRefClk(MCG); - break; - case kClockLptmrSrcLpoClk: /* LPO clock */ - freq = CLOCK_SYS_GetLpoClockFreq(); - break; - case kClockLptmrSrcEr32kClk: /* ERCLK32K clock */ - freq = CLOCK_SYS_GetExternalRefClock32kFreq(); - break; - case kClockLptmrSrcOsc0erClk: /* OSCERCLK clock */ - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUsbfFreq - * Description : Gets the clock frequency for USB FS OTG module. - * This function gets the clock frequency for USB FS OTG module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance) -{ - uint8_t usbdiv, usbfrac; - uint32_t freq; - clock_usbfs_src_t src; - - src = CLOCK_HAL_GetUsbfsSrc(SIM, instance); - - if (kClockUsbfsSrcExt == src) - { - return g_usbClkInFreq[0]; /* USB_CLKIN */ - } - else - { - freq = CLOCK_SYS_GetPllFllClockFreq(); - - CLOCK_HAL_GetUsbfsDiv(SIM, &usbdiv, &usbfrac); - return freq * (usbfrac + 1) / (usbdiv + 1); - } -} - - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetUartFreq - * Description : Gets the clock frequency for UART module. - * This function gets the clock frequency for UART module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance) -{ - uint32_t freq; - - switch (instance) - { - case 0: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 1: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - case 2: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - case 3: - freq = CLOCK_SYS_GetBusClockFreq(); - break; - case 4: - case 5: - - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSaiFreq - * Description : Gets the clock frequency for SAI module - * This function gets the clock frequency for SAI module. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc) -{ - uint32_t freq; - switch (saiSrc) - { - case kClockSaiSrcPllClk: - freq = CLOCK_HAL_GetPll0Clk(MCG); - break; - case kClockSaiSrcOsc0erClk: - freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq(); - break; - case kClockSaiSrcSysClk: - freq = CLOCK_SYS_GetSystemClockFreq(); - break; - default: - freq = 0U; - break; - } - - return freq; -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmExternalFreq - * Description : Gets FTM external clock frequency. - * - *END**************************************************************************/ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance) -{ - sim_ftm_clk_sel_t sel = SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); - - if (kSimFtmClkSel0 == sel) - { - return g_ftmClkFreq[0]; - } - else - { - return g_ftmClkFreq[1]; - } -} - -/* PORT instance table. */ -static const sim_clock_gate_name_t portGateTable[] = -{ - kSimClockGatePortA, - kSimClockGatePortB, - kSimClockGatePortC, - kSimClockGatePortD, - kSimClockGatePortE -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnablePortClock - * Description : Enable the clock for PORT module - * This function enables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_EnablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_EnableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisablePortClock - * Description : Disable the clock for PORT module - * This function disables the clock for PORT module - * - *END**************************************************************************/ -void CLOCK_SYS_DisablePortClock(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - SIM_HAL_DisableClock(SIM, portGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetPortGateCmd - * Description : Get the the clock gate state for PORT module - * This function will get the clock gate state for PORT module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance) -{ - assert(instance < sizeof(portGateTable)/sizeof(portGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, portGateTable[instance]); -} - -/* ADC instance table. */ -static const sim_clock_gate_name_t adcGateTable[] = -{ - kSimClockGateAdc0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableAdcClock - * Description : Enable the clock for ADC module - * This function enables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_EnableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableAdcClock - * Description : Disable the clock for ADC module - * This function disables the clock for ADC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableAdcClock(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - SIM_HAL_DisableClock(SIM, adcGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetAdcGateCmd - * Description : Get the the clock gate state for ADC module - * This function will get the clock gate state for ADC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance) -{ - assert(instance < sizeof(adcGateTable)/sizeof(adcGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, adcGateTable[instance]); -} - -/* DAC instance table. */ -static const sim_clock_gate_name_t dacGateTable[] = -{ - kSimClockGateDac0 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableDacClock - * Description : Enable the clock for DAC module - * This function enables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - SIM_HAL_EnableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableDacClock - * Description : Disable the clock for DAC module - * This function disables the clock for DAC module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableDacClock(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - - SIM_HAL_DisableClock(SIM, dacGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetDacGateCmd - * Description : Get the the clock gate state for DAC module - * This function will get the clock gate state for DAC module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance) -{ - assert(instance < sizeof(dacGateTable)/sizeof(dacGateTable[0])); - return SIM_HAL_GetGateCmd(SIM, dacGateTable[instance]); -} - -/* FTM instance table. */ -static const sim_clock_gate_name_t ftmGateTable[] = -{ - kSimClockGateFtm0, - kSimClockGateFtm1, - kSimClockGateFtm2, -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableFtmClock - * Description : Enable the clock for FTM module - * This function enables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_EnableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableFtmClock - * Description : Disable the clock for FTM module - * This function disables the clock for FTM module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableFtmClock(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - SIM_HAL_DisableClock(SIM, ftmGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetFtmGateCmd - * Description : Get the the clock gate state for FTM module - * This function will get the clock gate state for FTM module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance) -{ - assert(instance < sizeof(ftmGateTable)/sizeof(ftmGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, ftmGateTable[instance]); -} - -/* SPI instance table. */ -static const sim_clock_gate_name_t spiGateTable[] = -{ - kSimClockGateSpi0, - kSimClockGateSpi1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableSpiClock - * Description : Enable the clock for SPI module - * This function enables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_EnableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableSpiClock - * Description : Disable the clock for SPI module - * This function disables the clock for SPI module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableSpiClock(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - SIM_HAL_DisableClock(SIM, spiGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetSpiGateCmd - * Description : Get the the clock gate state for SPI module - * This function will get the clock gate state for SPI module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance) -{ - assert(instance < sizeof(spiGateTable)/sizeof(spiGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, spiGateTable[instance]); -} - -/* I2C instance table. */ -static const sim_clock_gate_name_t i2cGateTable[] = -{ - kSimClockGateI2c0, - kSimClockGateI2c1 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_EnableI2cClock - * Description : Enable the clock for I2C module - * This function enables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - SIM_HAL_EnableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_DisableI2cClock - * Description : Disable the clock for I2C module - * This function disables the clock for I2C module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableI2cClock(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - SIM_HAL_DisableClock(SIM, i2cGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : CLOCK_SYS_GetI2cGateCmd - * Description : Get the the clock gate state for I2C module - * This function will get the clock gate state for I2C module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance) -{ - assert(instance < sizeof(i2cGateTable)/sizeof(i2cGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, i2cGateTable[instance]); -} - -/* Uart instance table. */ -static const sim_clock_gate_name_t uartGateTable[] = -{ - kSimClockGateUart0, - kSimClockGateUart1, - kSimClockGateUart2, - kSimClockGateUart3 -}; - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_EnableUartClock - * Description : Enable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_EnableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_EnableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_DisableUartClock - * Description : Disable the clock for UART module - * This function enables the clock for UART module - * - *END**************************************************************************/ -void CLOCK_SYS_DisableUartClock(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - SIM_HAL_DisableClock(SIM, uartGateTable[instance]); -} - -/*FUNCTION********************************************************************** - * - * Function Name : SIM_HAL_GetUartGateCmd - * Description : Get the the clock gate state for UART module - * This function will get the clock gate state for UART module. - * - *END**************************************************************************/ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance) -{ - assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0])); - - return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]); -} - -/******************************************************************************* - * EOF - ******************************************************************************/ diff --git a/KSDK_1.2.0/platform/system/src/clock/MKW24D5/fsl_clock_MKW24D5.h b/KSDK_1.2.0/platform/system/src/clock/MKW24D5/fsl_clock_MKW24D5.h deleted file mode 100644 index 3add713..0000000 --- a/KSDK_1.2.0/platform/system/src/clock/MKW24D5/fsl_clock_MKW24D5.h +++ /dev/null @@ -1,1460 +0,0 @@ -/* - * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * o Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * o Neither the name of Freescale Semiconductor, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(__FSL_CLOCK_KW24DA5_H__) -#define __FSL_CLOCK_KW24DA5_H__ - -#include "fsl_mcg_hal.h" -#include "fsl_mcg_hal_modes.h" -#include "fsl_osc_hal.h" - -/*! @addtogroup clock_manager_kw24d5*/ -/*! @{*/ - -/*! @file*/ - -/******************************************************************************* - * Definitions - ******************************************************************************/ -/*! @brief USB external clock source count. */ -#define USB_EXT_CLK_COUNT 1 -/*! @brief FTM external clock source count. */ -#define FTM_EXT_CLK_COUNT 2 - -/*! @brief USB external clock frequency(USB_CLKIN). */ -extern uint32_t g_usbClkInFreq[USB_EXT_CLK_COUNT]; -/*! @brief FTM external clock frequency(FTM_CLK). */ -extern uint32_t g_ftmClkFreq[FTM_EXT_CLK_COUNT]; - -/*!@brief SIM configuration structure for dynamic clock setting. */ -typedef struct SimConfig -{ - clock_pllfll_sel_t pllFllSel; /*!< PLL/FLL/IRC48M selection. */ - clock_er32k_src_t er32kSrc; /*!< ERCLK32K source selection. */ - uint8_t outdiv1, outdiv2, outdiv3, outdiv4; /*!< OUTDIV setting. */ -#if (defined(DOXYGEN_OUTPUT) && (DOXYGEN_OUTPUT)) -} sim_config_kw24d5_t; -#else -} sim_config_t; -#endif - -/*! @brief Default clock configuration number. */ -#define CLOCK_CONFIG_NUM 2 - -/*! @brief Clock configuration index for VLPR mode. */ -#define CLOCK_CONFIG_INDEX_FOR_VLPR 0 - -/*! @brief Clock configuration index for RUN mode. */ -#define CLOCK_CONFIG_INDEX_FOR_RUN 1 - -/*! @} */ -/*! @addtogroup clock_manager*/ -/*! @{*/ -/******************************************************************************* - * API - ******************************************************************************/ - -#if defined(__cplusplus) -extern "C" { -#endif /* __cplusplus*/ - -/*! - * @brief Sets the clock out divider1 setting(OUTDIV1). - * - * This function sets divide value OUTDIV1. - * - * @param outdiv1 Outdivider1 setting - */ -static inline void CLOCK_SYS_SetOutDiv1(uint8_t outdiv1) -{ - CLOCK_HAL_SetOutDiv1(SIM, outdiv1); -} - -/*! - * @brief Gets the clock out divider1 setting(OUTDIV1). - * - * This function gets divide value OUTDIV1. - * - * @return Outdivider1 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv1(void) -{ - return CLOCK_HAL_GetOutDiv1(SIM); -} - -/*! - * @brief Sets the clock out divider2 setting(OUTDIV2). - * - * This function sets divide value OUTDIV2. - * - * @param outdiv2 Outdivider2 setting - */ -static inline void CLOCK_SYS_SetOutDiv2(uint8_t outdiv2) -{ - CLOCK_HAL_SetOutDiv2(SIM, outdiv2); -} - -/*! - * @brief Gets the clock out divider2 setting(OUTDIV2). - * - * This function gets divide value OUTDIV2. - * - * @return Outdivider2 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv2(void) -{ - return CLOCK_HAL_GetOutDiv2(SIM); -} - -/*! - * @brief Sets the clock out divider4 setting(OUTDIV4). - * - * This function sets divide value OUTDIV4. - * - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv4(uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv4(SIM, outdiv4); -} - -/*! - * @brief Gets the clock out divider4 setting(OUTDIV4). - * - * This function gets divide value OUTDIV4. - * - * @return Outdivider4 setting - */ -static inline uint8_t CLOCK_SYS_GetOutDiv4(void) -{ - return CLOCK_HAL_GetOutDiv4(SIM); -} - -/*! - * @brief Sets the clock out dividers setting. - * - * This function sets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_SetOutDiv(uint8_t outdiv1, uint8_t outdiv2, - uint8_t outdiv3, uint8_t outdiv4) -{ - CLOCK_HAL_SetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Gets the clock out dividers setting. - * - * This function gets the setting for all clock out dividers at the same time. - * - * @param outdiv1 Outdivider1 setting - * @param outdiv2 Outdivider2 setting - * @param outdiv3 Outdivider3 setting - * @param outdiv4 Outdivider4 setting - */ -static inline void CLOCK_SYS_GetOutDiv(uint8_t *outdiv1, uint8_t *outdiv2, - uint8_t *outdiv3, uint8_t *outdiv4) -{ - CLOCK_HAL_GetOutDiv(SIM, outdiv1, outdiv2, outdiv3, outdiv4); -} - -/*! - * @brief Get flexbus clock frequency. - * - * This function gets the flexbus clock frequency. - * - * @return Current flexbus clock frequency. - */ -uint32_t CLOCK_SYS_GetFlexbusFreq(void); - -/*! - * @brief Get the MCGPLLCLK/MCGFLLCLK/IRC48MCLK clock frequency. - * - * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. - * - * @return Current clock frequency. - */ -uint32_t CLOCK_SYS_GetPllFllClockFreq(void); - -/*! - * @brief Set PLL/FLL clock selection. - * - * This function sets the selection of the high frequency clock for - * various peripheral clocking options - * - * @param setting The value to set. - */ -static inline void CLOCK_SYS_SetPllfllSel(clock_pllfll_sel_t setting) -{ - CLOCK_HAL_SetPllfllSel(SIM, setting); -} - -/*! - * @brief Get PLL/FLL clock selection. - * - * This function gets the selection of the high frequency clock for - * various peripheral clocking options - * - * @return Current selection. - */ -static inline clock_pllfll_sel_t CLOCK_SYS_GetPllfllSel(void) -{ - return CLOCK_HAL_GetPllfllSel(SIM); -} - -/*! - * @brief Gets the MCGFFCLK clock frequency. - * - * This function gets the MCG fixed frequency clock (MCGFFCLK) frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetFixedFreqClockFreq(void) -{ - return CLOCK_HAL_GetFixedFreqClk(MCG); -} - -/*! - * @brief Get internal reference clock frequency. - * - * This function gets the internal reference clock frequency. - * - * @return Current clock frequency. - */ -static inline uint32_t CLOCK_SYS_GetInternalRefClockFreq(void) -{ - return CLOCK_HAL_GetInternalRefClk(MCG); -} - -/*! - * @brief Gets the external reference 32k clock frequency. - * - * This function gets the external reference (ERCLK32K) clock frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetExternalRefClock32kFreq(void); - -/*! - * @brief Set the clock selection of ERCLK32K. - * - * This function sets the clock selection of ERCLK32K. - * - * @param src clock source. - */ -static inline void CLOCK_SYS_SetExternalRefClock32kSrc(clock_er32k_src_t src) -{ - CLOCK_HAL_SetExternalRefClock32kSrc(SIM, src); -} - -/*! - * @brief Get the clock selection of ERCLK32K. - * - * This function gets the clock selection of ERCLK32K. - * - * @return Current selection. - */ -static inline clock_er32k_src_t CLOCK_SYS_GetExternalRefClock32kSrc(void) -{ - return CLOCK_HAL_GetExternalRefClock32kSrc(SIM); -} - -/*! - * @brief Gets the OSC0ERCLK frequency. - * - * This function gets the OSC0 external reference frequency. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetOsc0ExternalRefClockFreq(void); - -/*! - * @brief Gets RTC input clock frequency. - * - * This function gets the RTC input clock frequency. - * - * @param instance module device instance - * - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetRtcFreq(uint32_t instance) -{ - return g_xtalRtcClkFreq; -} - -/*! - * @brief Gets RTC_CLKOUT frequency. - * - * This function gets the frequency of RTC_CLKOUT. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetRtcOutFreq(void); - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function gets the source of RTC_CLKOUT. It is determined by RTCCLKOUTSEL. - * - * @return Current source. - */ -static inline clock_rtcout_src_t CLOCK_SYS_GetRtcOutSrc(void) -{ - return CLOCK_HAL_GetRtcClkOutSel(SIM); -} - -/*! - * @brief Gets RTC_CLKOUT source. - * - * This function sets the source of RTC_CLKOUT. - * - * @param src RTC_CLKOUT source to set. - */ -static inline void CLOCK_SYS_SetRtcOutSrc(clock_rtcout_src_t src) -{ - CLOCK_HAL_SetRtcClkOutSel(SIM, src); -} - -/*! - * @brief Gets the watch dog clock frequency. - * - * This function gets the watch dog clock frequency. - * - * @param instance module device instance - * @param wdogSrc watch dog clock source selection, WDOG_STCTRLH[CLKSRC]. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc); - -/*! - * @brief Gets the debug trace clock source. - * - * This function gets the debug trace clock source. - * @param instance module device instance - * - * @return Current source. - */ -static inline clock_trace_src_t CLOCK_SYS_GetTraceSrc(uint32_t instance) -{ - return CLOCK_HAL_GetTraceClkSrc(SIM); -} - -/*! - * @brief Sets the debug trace clock source. - * - * This function sets the debug trace clock source. - * @param instance module device instance. - * @param src debug trace clock source. - */ -static inline void CLOCK_SYS_SetTraceSrc(uint32_t instance, clock_trace_src_t src) -{ - CLOCK_HAL_SetTraceClkSrc(SIM, src); -} - -/*! - * @brief Gets the debug trace clock frequency. - * - * This function gets the debug trace clock frequency. - * @param instance module device instance - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetTraceFreq(uint32_t instance); - -/*! - * @brief Gets PORTx digital input filter clock frequency. - * - * This function gets the PORTx digital input filter clock frequency. - * @param instance module device instance. - * @param src PORTx source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetPortFilterFreq(uint32_t instance, clock_port_filter_src_t src); - -/*! - * @brief Gets LPTMRx pre-scaler/glitch filter clock frequency. - * - * This function gets the LPTMRx pre-scaler/glitch filter clock frequency. - * - * @param instance module device instance - * @param lptmrSrc LPTMRx clock source selection. - * - * @return Current frequency. - */ -uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc); - - -/*! - * @brief Gets the clock frequency for EWM module. - * - * This function gets the clock frequency for EWM module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetEwmFreq(uint32_t instance) -{ - return CLOCK_SYS_GetLpoClockFreq(); -} - -/*! - * @brief Gets the clock frequency for FTF module. (Flash Memory) - * - * This function gets the clock frequency for FTF module. (Flash Memory) - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetFtfFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFlashClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CRC module. - * - * This function gets the clock frequency for CRC module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCrcFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMP module. - * - * This function gets the clock frequency for CMP module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmpFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for VREF module. - * - * This function gets the clock frequency for VREF module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetVrefFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PDB module. - * - * This function gets the clock frequency for PDB module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPdbFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for PIT module. - * - * This function gets the clock frequency for PIT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetPitFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for CMT module. - * - * This function gets the clock frequency for CMT module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetCmtFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock source for USB FS OTG module - * - * This function gets the clock source for USB FS OTG module. - * @param instance module device instance - * @return Clock source. - */ -static inline clock_usbfs_src_t CLOCK_SYS_GetUsbfsSrc(uint32_t instance) -{ - return CLOCK_HAL_GetUsbfsSrc(SIM, instance); -} - -/*! - * @brief Sets the clock source for USB FS OTG module - * - * This function sets the clock source for USB FS OTG module. - * @param instance module device instance. - * @param usbfsSrc USB FS clock source setting. - */ -static inline void CLOCK_SYS_SetUsbfsSrc(uint32_t instance, clock_usbfs_src_t usbfsSrc) -{ - CLOCK_HAL_SetUsbfsSrc(SIM, instance, usbfsSrc); -} - -/*! - * @brief Gets the clock frequency for USB FS OTG module - * - * This function gets the clock frequency for USB FS OTG module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUsbfsFreq(uint32_t instance); - -/*! - * @brief Set USB FS divider setting. - * - * This function sets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_SetUsbfsDiv(uint32_t instance, - uint8_t usbdiv, - uint8_t usbfrac) -{ - CLOCK_HAL_SetUsbfsDiv(SIM, usbdiv, usbfrac); -} - -/*! - * @brief Get USB FS divider setting. - * - * This function gets USB FS divider setting. - * Divider output clock = Divider input clock * [ (USBFSFRAC+1) / (USBFSDIV+1) ] - * - * @param instance USB FS module instance. - * @param usbdiv Value of USBFSDIV. - * @param usbfrac Value of USBFSFRAC. - */ -static inline void CLOCK_SYS_GetUsbfsDiv(uint32_t instance, - uint8_t *usbdiv, - uint8_t *usbfrac) -{ - CLOCK_HAL_GetUsbfsDiv(SIM, usbdiv, usbfrac); -} - - - -/*! - * @brief Gets the clock frequency for SAI. - * - * This function gets the clock frequency for SAI. - * - * @param instance module device instance. - * @param saiSrc SAI clock source selection according to its internal register. - * @return freq clock frequency for this module. - */ -uint32_t CLOCK_SYS_GetSaiFreq(uint32_t instance, clock_sai_src_t saiSrc); - -/*! - * @brief Gets the clock frequency for USB DCD module - * - * This function gets the clock frequency for USB DCD module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetUsbdcdFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for SPI module - * - * This function gets the clock frequency for SPI module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetSpiFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets the clock frequency for I2C module - * - * This function gets the clock frequency for I2C module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetI2cFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets ADC alternate clock frequency. - * - * This function gets the ADC alternate clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetAdcAltFreq(uint32_t instance) -{ - return CLOCK_SYS_GetOsc0ExternalRefClockFreq(); -} - -/*! - * @brief Gets FTM fixed frequency clock frequency. - * - * This function gets the FTM fixed frequency clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance) -{ - return CLOCK_SYS_GetFixedFreqClockFreq(); -} - -/*! - * @brief Gets FTM's system clock frequency. - * - * This function gets the FTM's system clock frequency. - * - * @param instance module device instance - * @return Current frequency. - */ -static inline uint32_t CLOCK_SYS_GetFtmSystemClockFreq(uint32_t instance) -{ - return CLOCK_SYS_GetBusClockFreq(); -} - -/*! - * @brief Gets FTM external clock frequency. - * - * This function gets the FTM external clock frequency. - * - * @param instance module device instance - * @return freq Current frequency. - */ -uint32_t CLOCK_SYS_GetFtmExternalFreq(uint32_t instance); - -/*! - * @brief Gets FTM external clock source. - * - * This function gets the FTM external clock source. - * - * @param instance module device instance. - * @return Ftm external clock source. - */ -static inline sim_ftm_clk_sel_t CLOCK_SYS_GetFtmExternalSrc(uint32_t instance) -{ - return SIM_HAL_GetFtmExternalClkPinMode(SIM, instance); -} - -/*! - * @brief Sets FTM external clock source. - * - * This function sets the FTM external clock source. - * - * @param instance module device instance. - * @param ftmSrc FTM clock source setting. - */ -static inline void CLOCK_SYS_SetFtmExternalSrc(uint32_t instance, - sim_ftm_clk_sel_t ftmSrc) -{ - SIM_HAL_SetFtmExternalClkPinMode(SIM, instance, ftmSrc); -} - -/*! - * @brief Gets the clock frequency for UART module - * - * This function gets the clock frequency for UART module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -uint32_t CLOCK_SYS_GetUartFreq(uint32_t instance); - -/*! - * @brief Gets the clock frequency for GPIO module - * - * This function gets the clock frequency for GPIO module. - * @param instance module device instance - * @return freq clock frequency for this module - */ -static inline uint32_t CLOCK_SYS_GetGpioFreq(uint32_t instance) -{ - return CLOCK_SYS_GetSystemClockFreq(); -} - -/*! - * @brief Enable the clock for DMA module. - * - * This function enables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Disable the clock for DMA module. - * - * This function disables the clock for DMA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDma0); -} - -/*! - * @brief Get the the clock gate state for DMA module. - * - * This function will get the clock gate state for DMA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDma0); -} - -/*! - * @brief Enable the clock for DMAMUX module. - * - * This function enables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableDmamuxClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Disable the clock for DMAMUX module. - * - * This function disables the clock for DMAMUX module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableDmamuxClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Get the the clock gate state for DMAMUX module. - * - * This function will get the clock gate state for DMAMUX module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetDmamuxGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateDmamux0); -} - -/*! - * @brief Enable the clock for PORT module. - * - * This function enables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_EnablePortClock(uint32_t instance); - -/*! - * @brief Disable the clock for PORT module. - * - * This function disables the clock for PORT module. - * @param instance module device instance - */ -void CLOCK_SYS_DisablePortClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for PORT module. - * - * This function will get the clock gate state for PORT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetPortGateCmd(uint32_t instance); - - -/*! - * @brief Enable the clock for EWM module. - * - * This function enables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableEwmClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Disable the clock for EWM module. - * - * This function disables the clock for EWM module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableEwmClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateEwm0); -} - -/*! - * @brief Get the the clock gate state for EWM module. - * - * This function will get the clock gate state for EWM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetEwmGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateEwm0); -} - - -/*! - * @brief Enable the clock for FTF module. - * - * This function enables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableFtfClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Disable the clock for FTF module. - * - * This function disables the clock for FTF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableFtfClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Get the the clock gate state for FTF module. - * - * This function will get the clock gate state for FTF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetFtfGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateFtf0); -} - -/*! - * @brief Enable the clock for CRC module. - * - * This function enables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCrcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Disable the clock for CRC module. - * - * This function disables the clock for CRC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCrcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Get the the clock gate state for CRC module. - * - * This function will get the clock gate state for CRC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCrcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCrc0); -} - -/*! - * @brief Enable the clock for RNGA module. - * - * This function enables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRngaClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Disable the clock for RNGA module. - * - * This function disables the clock for RNGA module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRngaClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Get the the clock gate state for RNGA module. - * - * This function will get the clock gate state for RNGA module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRngaGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRnga0); -} - -/*! - * @brief Enable the clock for ADC module. - * - * This function enables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableAdcClock(uint32_t instance); - -/*! - * @brief Disable the clock for ADC module. - * - * This function disables the clock for ADC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableAdcClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for ADC module. - * - * This function will get the clock gate state for ADC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetAdcGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for CMP module. - * - * This function enables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmpClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Disable the clock for CMP module. - * - * This function disables the clock for CMP module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmpClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmp); -} - -/*! - * @brief Get the the clock gate state for CMP module. - * - * This function will get the clock gate state for CMP module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmpGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmp); -} - -/*! - * @brief Enable the clock for DAC module. - * - * This function enables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableDacClock(uint32_t instance); - -/*! - * @brief Disable the clock for DAC module. - * - * This function disables the clock for DAC module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableDacClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for DAC module. - * - * This function will get the clock gate state for DAC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetDacGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for VREF module. - * - * This function enables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableVrefClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Disable the clock for VREF module. - * - * This function disables the clock for VREF module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableVrefClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateVref0); -} - -/*! - * @brief Get the the clock gate state for VREF module. - * - * This function will get the clock gate state for VREF module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetVrefGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateVref0); -} - -/*! - * @brief Enable the clock for SAI module. - * - * This function enables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableSaiClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Disable the clock for SAI module. - * - * This function disables the clock for SAI module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableSaiClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateSai0); -} - -/*! - * @brief Get the the clock gate state for SAI module. - * - * This function will get the clock gate state for SAI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetSaiGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateSai0); -} - -/*! - * @brief Enable the clock for PDB module. - * - * This function enables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePdbClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Disable the clock for PDB module. - * - * This function disables the clock for PDB module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePdbClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Get the the clock gate state for PDB module. - * - * This function will get the clock gate state for PDB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPdbGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePdb0); -} - -/*! - * @brief Enable the clock for FTM module. - * - * This function enables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableFtmClock(uint32_t instance); - -/*! - * @brief Disable the clock for FTM module. - * - * This function disables the clock for FTM module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableFtmClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for FTM module. - * - * This function will get the clock gate state for FTM module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetFtmGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for PIT module. - * - * This function enables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnablePitClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Disable the clock for PIT module. - * - * This function disables the clock for PIT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisablePitClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGatePit0); -} - -/*! - * @brief Get the the clock gate state for PIT module. - * - * This function will get the clock gate state for PIT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetPitGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGatePit0); -} - -/*! - * @brief Enable the clock for LPTIMER module. - * - * This function enables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableLptmrClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Disable the clock for LPTIMER module. - * - * This function disables the clock for LPTIMER module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableLptmrClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Get the the clock gate state for LPTIMER module. - * - * This function will get the clock gate state for LPTIMER module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetLptmrGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateLptmr0); -} - -/*! - * @brief Enable the clock for CMT module. - * - * This function enables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableCmtClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Disable the clock for CMT module. - * - * This function disables the clock for CMT module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableCmtClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Get the the clock gate state for CMT module. - * - * This function will get the clock gate state for CMT module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetCmtGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateCmt0); -} - -/*! - * @brief Enable the clock for RTC module. - * - * This function enables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableRtcClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Disable the clock for RTC module. - * - * This function disables the clock for RTC module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableRtcClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Get the the clock gate state for RTC module. - * - * This function will get the clock gate state for RTC module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetRtcGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateRtc0); -} - -/*! - * @brief Enable the clock for USBFS module. - * - * This function enables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbfsClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Disable the clock for USBFS module. - * - * This function disables the clock for USBFS module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbfsClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Get the the clock gate state for USB module. - * - * This function will get the clock gate state for USB module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbfsGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbfs0); -} - -/*! - * @brief Enable the clock for USBDCD module. - * - * This function enables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_EnableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_EnableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Disable the clock for USBDCD module. - * - * This function disables the clock for USBDCD module. - * @param instance module device instance - */ -static inline void CLOCK_SYS_DisableUsbdcdClock(uint32_t instance) -{ - SIM_HAL_DisableClock(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Get the the clock gate state for USBDCD module. - * - * This function will get the clock gate state for USBDCD module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -static inline bool CLOCK_SYS_GetUsbdcdGateCmd(uint32_t instance) -{ - return SIM_HAL_GetGateCmd(SIM, kSimClockGateUsbdcd0); -} - -/*! - * @brief Enable the clock for SPI module. - * - * This function enables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableSpiClock(uint32_t instance); - -/*! - * @brief Disable the clock for SPI module. - * - * This function disables the clock for SPI module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableSpiClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for SPI module. - * - * This function will get the clock gate state for SPI module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetSpiGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for I2C module. - * - * This function enables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableI2cClock(uint32_t instance); - -/*! - * @brief Disable the clock for I2C module. - * - * This function disables the clock for I2C module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableI2cClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for I2C module. - * - * This function will get the clock gate state for I2C module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetI2cGateCmd(uint32_t instance); - -/*! - * @brief Enable the clock for UART module. - * - * This function enables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_EnableUartClock(uint32_t instance); - -/*! - * @brief Disable the clock for UART module. - * - * This function disables the clock for UART module. - * @param instance module device instance - */ -void CLOCK_SYS_DisableUartClock(uint32_t instance); - -/*! - * @brief Get the the clock gate state for UART module. - * - * This function will get the clock gate state for UART module. - * @param instance module device instance - * @return state true - ungated(Enabled), false - gated (Disabled) - */ -bool CLOCK_SYS_GetUartGateCmd(uint32_t instance); - -#if defined(__cplusplus) -} -#endif /* __cplusplus*/ - -/*! @}*/ - -#endif /* __FSL_CLOCK_KW24DA5_H__ */ -/******************************************************************************* - * EOF - ******************************************************************************/ - -- cgit v1.2.3-18-g5258